Golang MSSQL driver for Windows7 64-bit

10,079

Solution 1

Try using this ODBC driver instead, I believe it is more widely used: https://code.google.com/p/odbc/

Solution 2

Now, there is a Microsoft SQL Server specific driver on the database driver list SQL database drivers in github with a pure Go package https://github.com/denisenkom/go-mssqldb

You could try go-mssqldb to connect mssql directly.

The import could look like:

import (
    "fmt"
    "log"
    "database/sql"
     _ "github.com/denisenkom/go-mssqldb"     // the underscore indicates the package is used
)    

the sql.Open() looks like:

// the user needs to be setup in SQL Server as an SQL Server user.
// see create login and the create user SQL commands as well as the
// SQL Server Management Studio documentation to turn on Hybrid Authentication
// which allows both Windows Authentication and SQL Server Authentication.
// also need to grant to the user the proper access permissions.
// also need to enable TCP protocol in SQL Server Configuration Manager.
condb, errdb := sql.Open("mssql", "server=localhost;user id=gouser;password=g0us3r;")
if errdb  != nil {
    fmt.Println("  Error open db:", errdb.Error())
}

defer condb.Close()

and I am using it, it's ok for now.

Share:
10,079

Related videos on Youtube

slachterman
Author by

slachterman

Updated on September 14, 2022

Comments

  • slachterman
    slachterman over 1 year

    I am trying to connect to a Microsoft SQL Server database using the database/sql package for golang.

    There is no MSSQL-specific driver listed at https://code.google.com/p/go-wiki/wiki/SQLDrivers, so I thought I'd try an odbc driver.

    I tried https://github.com/weigj/go-odbc but when I run go install I receive cc1.exe: sorry, unimplemented: 64-bit mode not compiled in. This is listed as an open issue in the github repo.

    Does anyone have experience connecting to an MSSQL database from a 64-bit Windows 7 client? Which odbc driver is recommended?

  • juliocesar
    juliocesar about 10 years
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
  • Tracker1
    Tracker1 about 9 years
    Also, depending on your platform, may need to use FreeTDS over the Microsoft ODBC SQL Adapter for ODBC clients (specifically non-windows).