現在,有數據庫驅動程序列表SQL database drivers在Microsoft SQL Server特定的驅動程序在github上與純圍棋包https://github.com/denisenkom/go-mssqldb
您可以嘗試go-mssqldb
直接連接mssql
。
的import
可能看起來像:
import (
"fmt"
"log"
"database/sql"
_ "github.com/denisenkom/go-mssqldb" // the underscore indicates the package is used
)
的sql.Open()
樣子:
// 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()
,我使用它,這是確定的了。
https://code.google.com/p/odbc – alex
亞歷克斯,你能提供一個使用該驅動程序的sql.Open()調用的例子嗎?是否需要使用DSN或可以指定連接字符串?謝謝。 – slachterman
https://code.google.com/p/odbc/source/browse/mssql_test.go#56 – alex