I'm attempting to connect to a data source with a 3rd party ODBC driver (downloadable here) in Go using the alexbrainman ODBC driver. I've tested the DSN in question using:
isql -v "CData Redis Source"
Everything works as expected there. And I know that I have unixODBC 2.3.1 installed (isql --version
).
When I try to run the following Go program, I get this error message, spawned from the db.Ping()
call (which Google translate seems unable to translate):
SQLDriverConnect: {こ0} [unixODBC]湉慶楬潣湮捥楴湯猠牴湩祳瑮硡愠⁴湩敤⁸ㅛ㩝
My code:
package main
import (
_ "github.com/alexbrainman/odbc"
"database/sql"
"log"
)
func main() {
db, err := sql.Open("odbc","DSN=CData Redis Source")
if err != nil {
log.Fatal(err);
}
var (
name string
)
rows, err := db.Ping()
if err != nil {
log.Fatal(err)
}
}
I see the same error if I do a db.Query()
or a db.Prepare()
.
I'd be happy with a translation of the error message to help me debug AND/OR some help in determining why my error message is not in English AND/OR an actual proposed solution to the error message.
It turns out that I needed to ensure that the CData Driver was configured to use UTF-16 encoding, as is required by unixODBC. To do so, I edited the driver's INI file:
/opt/cdata/cdata-odbc-driver-for-redis/lib/cdata.odbc.redis.ini
[Driver]
DriverManagerEncoding = UTF-16
Once this was done the CData driver worked with the alexbrainman/odbc database driver (and other Go-related ODBC database drivers) as expected.