Is there a package that implements the sql.DB interface and stores the database in a file?

I am looking for a Go package that implements the official sql interface but stores everything in a single file as I don’t need advanced functions.

It does not need to behave like a SQL database requiring queries, drivers, or the like.

I believe you’re looking for SQLite:

And here’s an article to get you started:


@Willy I found a pain to use on some platforms because it requires cgo.
Luckily there’s a conversion of this db-driver to pure go:

Many tutorials don’t mention this option.

how do I confirm that implements the sql.DB interface? i don’t see it at a glance.

AFAIK it’s a drop-in replacement of mattn/go-sqlite3.
Here’s a simple example from the gitlab-repo: examples/example1/main.go · master · cznic / sqlite · GitLab

I’ve started using GitHub - glebarez/go-sqlite: pure-Go SQLite driver for Go (SQLite embedded), didn’t realize there were so many options…

I had never found that one. Seems to be a fork of modernc with slight modifications to make it more compatible with GORM:

Where is the documentation for that package?

All documentation on is generated from the parsed code and the files in the git-repositories (Github/Gitlab/…). It’s a Google Service AFAIK. If you have the links to the repositories, it’s really not that hard to find the (reference) documentation. Or do you mean something else?

1 Like

Here’s the godoc:

I believe it’s minimal on the documentation front because it’s just a SQL driver. Check out the example to get going if you choose to use this module:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.