Golang database/sql.DB.Driver function example
package database/sql
Driver returns the database's underlying driver.
Golang database/sql.DB.Driver function usage example
var ( dbType = flag.String("dbType", "sqlite3", "db type") dbUrl = flag.String("dbUrl", "sdata.db", "db url") )
db, _ := sql.Open(*dbType, *dbUrl)
conn, err := db.Driver().Open(*dbUrl) // <-- here
if conn == nil {
t.Fatal("driver.Open not properly set: didn't connect")
}
defer db.Close()
result, err := db.Exec("insert into t_sdata (data,tp) values(?,?)", data, _type)
...
Reference :
Advertisement
Something interesting
Tutorials
+9.6k Golang : How to extract video or image files from html source code
+12.8k Golang : Listen and Serve on sub domain example
+18.8k Golang : Delete duplicate items from a slice/array
+4.7k Javascript : Access JSON data example
+33.9k Golang : Call a function after some delay(time.Sleep and Tick)
+12.1k Golang : Pagination with go-paginator configuration example
+9.7k Golang : Sort and reverse sort a slice of floats
+8.2k Golang : Get final or effective URL with Request.URL example
+12.5k Golang : Forwarding a local port to a remote server example
+5.5k Golang : Display advertisement images or strings on random order
+17.2k Golang : Find file size(disk usage) with filepath.Walk
+6.9k Golang : How to solve "too many .rsrc sections" error?