SQLite Production Configuration

Notes taken from Ben Johnson’s talk Building Production Applications Using Go & SQLite.

The complete list of pragmas can be found on SQLite’s official website.

Journal Mode

Journal mode configures how SQLite writes transactions. You almost always want it as WAL (write ahead log).

PRAGMA journal_mode = WAL;

Busy Timeout

Busy timeout sets how long write transactions will wait to start. If unset, writes will fail immediately if another write is running. Five seconds might be enough… most of the times.

PRAGMA busy_timeout = 5000;

Foreign Keys

Believe it or not, for historical reasons foreign keys are not enforced by default.

PRAGMA foreign_keys = ON;

Usage in Go

This is a Go example showing how to use the options above with the github.com/mattn/go-sqlite3 driver.

db, err := sql.Open(
    "sqlite3",
    "file.db?_busy_timeout=5000&_journal_mode=WAL&_foreign_keys=on",
)
if err != nil {
    log.Fatalln("could not open database: %w", err)
}
defer func() {
    if err := db.Close(); err != nil {
        log.Fatalln("could not close database: %w", err)
	  }
}()

Articles from blogs I follow around the net

The four tenets of SOA revisited

Twenty years after. In the January 2004 issue of MSDN Magazine you can find an article by Don Box titled A Guide to Developing and Running Connected Systems with Indigo. Buried within the (now dated) discussion of the technology…

via ploeh blog March 4, 2024

Building a demo of the Bleichenbacher RSA attack in Rust

Recently while reading Real-World Cryptography, I got nerd sniped1 by the mention of Bleichenbacher's attack on RSA. This is cool, how does it work? I had to understand, and to understand something, I usually have to build it. Well, friends, that is what…

via ntietz.com blog March 4, 2024

How to unbreak Dolphin on SteamOS after the QT6 update

A recent update to Dolphin made it switch to QT6. This makes it crash with this error or something like it: dolphin-emu: symbol lookup error: dolphin-emu: undefined symbol: _Zls6QDebugRK11QDockWidget, version Qt_6 This is fix…

via Xe Iaso's blog March 3, 2024

Generated by openring