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
+11.5k CodeIgniter : Import Linkedin data
+6.3k Unix/Linux : Use netstat to find out IP addresses served by your website server
+22.2k Golang : Securing password with salt
+6k Javascript : Get operating system and browser information
+6k PHP : How to check if an array is empty ?
+41.9k Golang : How do I convert int to uint8?
+8.5k Golang : How to check if input string is a word?
+29.1k Golang : Get first few and last few characters from string
+15.6k Golang : ROT47 (Caesar cipher by 47 characters) example
+11.6k Swift : Convert (cast) Float to String
+9.6k Golang : Quadratic example
+12.1k Golang : Decompress zlib file example