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
+8k Golang : What fmt.Println() can do and println() cannot do
+18.1k Golang : Check if a directory exist or not
+22.9k Golang : Gorilla mux routing example
+6.7k Golang : Check if password length meet the requirement
+6.9k Android Studio : Hello World example
+29.4k Golang : JQuery AJAX post data to server and send data back to client example
+12.2k Golang : Simple client-server HMAC authentication without SSL example
+21.8k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+16.5k Golang : File path independent of Operating System
+5.9k Golang : Denco multiplexer example
+5.3k Golang : Pad file extension automagically