sql - golang database Open function ambiguity -



sql - golang database Open function ambiguity -

in go, invoke database open

db, err = sql.open("sqlite3", "./bar.db")

this returns database of type *sql.db, function , type both members of database/sql.

however, in sqlite3 driver package, there open function returns *sqlite3.conn type.

i've noticed of functions defined in sqlite3 driver bundle not work on database opened using default database/sql.

additionally, there functions in sqlite3 bundle similar database/sql's functions, namely query , exec, homecoming different types.

database/sql contains func query returns type *sql.rows.

mxk/sqlite/sqlite3 , mattn/go-sqlite3 both have query function, homecoming different types.

i want run functions such mxk/sqlite/sqlite3's busytimeout on database connection, isn't right type. have re-write of code open database connection sqlite3 driver instead of using database/sql's open? what's advantage of database/sql's open function if can't utilize of driver's functions generic connection?

well, docs state...

database connections created either using bundle straight or "sqlite3" database/sql driver. direct interface, described below, exposes sqlite-specific features, such incremental i/o , online backups. driver recommended when application has back upwards multiple database engines.

... utilize sqlite3 connection when want sqlite specific functions (your usecase) , generic database connections utilize database driver (your code).

that logical, since how generic driver handle functions specific various databases? runtime errors?

so have choice: sqlite functions -> sqlite conn or handle multiple sql databases -> generic driver.

sql sqlite sqlite3 go

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -