litesql
litesql is a Go library that provides an abstraction for correctly using SQLite in Go programs. It pools connections for read transactions, isolates a dedicated write connection for writes, sets more reasonable pragma defaults (isolation levels, foreign keys, cache sizes), offers an abstraction for creating periodic snapshots with retention policies, and includes litesqltest for one-line test database creation in unit tests.
What it addresses
Using SQLite in Go with the default database/sql driver works until SQLITE_BUSY errors appear as traffic increases, and developers face conflicting information on best practices for pragma values and connection handling.
Shared over time
Each entry reflects what was shared on that date. Details may have changed since then.
litesql
litesql is a Go library that provides an abstraction for correctly using SQLite in Go programs. It pools connections for read transactions, isolates a dedicated write connection for writes, sets more reasonable pragma defaults (isolation levels, foreign keys, cache sizes), offers an abstraction for creating periodic snapshots with retention policies, and includes litesqltest for one-line test database creation in unit tests.
Problem: Using SQLite in Go with the default database/sql driver works until SQLITE_BUSY errors appear as traffic increases, and developers face conflicting information on best practices for pragma values and connection handling.
Audience: Go developers
Posted by @sethops1 · Original source ↗
Submitted URL · @sethops1 · · Source ↗
https://github.com/cattlecloud/litesql
Source text · @sethops1 · · Source ↗
Which provides a nice abstraction, making it easy to accidentally do the right things when using SQLite in your Go program.
Source text · @sethops1 · · Source ↗
In particular it pools connections for read transactions and isolates a dedicated write connection for writes. It also sets pragma values to much more reasonable defaults, like isolation levels, foreign keys, cache sizes, etc.
Source text · @sethops1 · · Source ↗
If you just import the popular github.com/mattn/go-sqlite3 as the database/sql driver implementation and start making queries, things will work great until you start hitting SQLITE_BUSY errors as traffic increases.
Source text · @sethops1 · · Source ↗
Then you go down the same path of many gophers before you, finding GitHub and forum posts providing conflicting information on best practices for pragma values and connection handling.
Story title · @sethops1 · · Source ↗
Show HN: I created a library for correctly using SQLite in Go programs