func TestOdbc(t *testing.T) { conn, e := odbc.Connect("DSN=mysql-dsn;UID=root;PWD=root") if e != nil { toolkit.Println("Conn Error found: ", e.Error()) } toolkit.Println(conn) query := "SELECT id, name FROM dummy" stmt, e := conn.Prepare(query) if e != nil { toolkit.Println("STMT Error found: ", e.Error()) } // toolkit.Println(conn, stmt) e = stmt.Execute() if e != nil { toolkit.Println("Execute Error found: ", e.Error()) } rows, e := stmt.FetchAll() if e != nil { toolkit.Println("FetchAll Error found: ", e.Error()) } // toolkit.Println(toolkit.JsonString(rows)) for _, row := range rows { toolkit.Printf("%v\n", row.Data) } stmt.Close() conn.Close() }
func (d *Driver) Open(dsn string) (driver.Conn, error) { c, err := odbc.Connect(dsn) if err != nil { return nil, err } conn := &conn{c: c} return conn, nil }
func (c *Connection) OdbcConnect(connector string, stringConnection string) error { odbcconn, e := odbc.Connect(stringConnection) if e != nil { return err.Error(packageName, modConnection, "ODBC Connect", e.Error()) } c.Sess = odbcconn /*sqlcon, er := sql.Open(connector, stringConnection) if er != nil { return err.Error(packageName, modConnection, "SQL Open", e.Error()) } c.Sql = sqlcon er = sqlcon.Ping() if er != nil { return err.Error(packageName, modConnection, "Ping", e.Error()) }*/ return nil }