ODBC database driver for GO:GO access to SQL Server through ODBC

Source: Internet
Author: User
Tags odbc git clone

The go language accesses SQL Server through ODBC, which needs to use the GO-ODBC Library, open Source address:: Https://github.com/weigj/go-odbc

First, drive installation

Open the Gopath in cmd:

Go to src Directory

In the SRC directory, get the ODBC driver via git:

git clone git://github.com/weigj/go-odbc.git ODBC

Go to the ODBC directory:

Run the Go Install command:

prompt does not install GCC compiler, to the official website download http://tdm-gcc.tdragon.net/ .

Ii. installation of GCC

or download Mingw-w64-install.exe (170.0 KB), reboot after installation.

is the Mingw-w64-install.exe (https://sourceforge.net/projects/mingw-w64/) installation process:

Configure the GCC environment, open system variables, modify path, add E:\Program files\mingw-w64\x86_64-5.3.0-posix-seh-rt_v4-rev0\mingw64\bin, such as:

Run the Go install command again without prompting for an error message, such as:

Iii. Examples of programs

Idea: Link database--Create a query--display query results

Package Mainimport ("FMT" "ODBC") Func main () {FMT. Printf ("%s\n", "CREATE Database Link") conn, _: = ODBC. Connect ("DSN=DTCMS; Uid=user; [email protected] ") stmt, _: = conn. Prepare ("SELECT top * from Dt_article") stmt. Execute () rows, err: = stmt. Fetchall () if err! = Nil {fmt. PRINTLN (Err) return}for I, row: = Range rows {Println (i, Row)}stmt. Close () Conn. Close () return}

ODBC database driver for GO:GO access to SQL Server through ODBC

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.