In go, you invoke a database open with
DB, err = sql.Open("sqlite3", "./bar.db")
This returns a database of type *sql.DB
, the function and type are both members of database/sql
.
However, in the sqlite3 driver package, there is another Open
function which returns a *sqlite3.Conn
type.
I've noticed that some of the functions defined in the sqlite3
driver package do not work on a database opened using the default database/sql
.
Additionally, there are functions in the sqlite3 package that are similar to database/sql
's functions, namely Query
and Exec
, which return different types.
database/sql
contains a func Query
that returns type *sql.Rows
.
mxk/sqlite/sqlite3
and mattn/go-sqlite3
both have a Query
function, which return completely different types.
I want to run functions such as mxk/sqlite/sqlite3
's BusyTimeout
on my database connection, but it isn't the correct type. Do I have to re-write all of my code to open the database connection with the sqlite3 driver instead of using database/sql
's Open
? What's the advantage of database/sql
's Open
function if you can't use any of the driver's functions with that generic connection?