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
+21.1k Golang : Get password from console input without echo or masked
+4.6k JavaScript : Rounding number to decimal formats to display currency
+7.9k Golang : Grayscale Image
+6.2k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations
+16.9k Golang : Get the IPv4 and IPv6 addresses for a specific network interface
+5.8k Unix/Linux : How to test user agents blocked successfully ?
+5.6k Swift : Get substring with rangeOfString() function example
+22.8k Golang : untar or extract tar ball archive example
+17k Golang : Covert map/slice/array to JSON or XML format
+9.4k Golang : Qt Yes No and Quit message box example
+6.4k PHP : Proper way to get UTF-8 character or string length
+20.6k Golang : Secure(TLS) connection between server and client