sqlite database usage

1,110 views
Skip to first unread message

Brandon Mercer

unread,
Apr 22, 2012, 5:16:50 PM4/22/12
to golang-nuts
Hello, I'm trying to access a sqlite database from within my web application. This is go1 on openbsd amd64. I've started with:
go get github.com/mattn/go-sqlite3
I have sqlite3-3.7.11 installed from ports. When I try to run the tests for this package I get:
$ go test--- FAIL: TestOpen (0.00 seconds)sqlite3_test.go:12: Failed to open database:%!(EXTRA *errors.errorString=sql: unknown driver "sqlite3" (forgotten import?))--- FAIL: TestInsert (0.00 seconds)sqlite3_test.go:32: Failed to open database:%!(EXTRA *errors.errorString=sql: unknown driver "sqlite3" (forgotten import?))--- FAIL: TestUpdate (0.00 seconds)sqlite3_test.go:74: Failed to open database:%!(EXTRA *errors.errorString=sql: unknown driver "sqlite3" (forgotten import?))--- FAIL: TestDelete (0.00 seconds)sqlite3_test.go:148: Failed to select records:%!(EXTRA *errors.errorString=sql: unknown driver "sqlite3" (forgotten import?))--- FAIL: TestBooleanRoundtrip (0.00 seconds)sqlite3_test.go:216: Tailed to open database:%!(EXTRA *errors.errorString=sql: unknown driver "sqlite3" (forgotten import?))FAILexit status 1FAIL github.com/mattn/go-sqlite3 0.006s

I'm not quite sure where to go from here, my application fails the same way. Thanks
Brandon

Nigel Tao

unread,
Apr 22, 2012, 8:06:26 PM4/22/12
to Brandon Mercer, golang-nuts
On 23 April 2012 07:16, Brandon Mercer <yourcom...@gmail.com> wrote:
> $ go test--- FAIL: TestOpen (0.00 seconds)sqlite3_test.go:12: Failed to open
> database:%!(EXTRA *errors.errorString=sql: unknown driver "sqlite3"
> (forgotten import?))

The "forgotten import" is a clue. Try adding
import _ "github.com/mattn/go-sqlite3"
to your main program.

Kyle Lemons

unread,
Apr 22, 2012, 8:12:56 PM4/22/12
to Nigel Tao, Brandon Mercer, golang-nuts
He was running mattn's built-in tests, which pass fine for me.  We debugged this more on IRC and it looks like something is broken about cgo on OpenBSD, and the package either ends up coming out with no code or something prevents it from init'ing properly.
Reply all
Reply to author
Forward
0 new messages