hn.today

Show HN: I created a library for correctly using SQLite in Go programs

github.com23 points2 comments
Screenshot of Show HN: I created a library for correctly using SQLite in Go programs

litesql is an open-source Go library designed to make SQLite access convenient, reliable, and performant, with defaults aimed at common applications such as web services. Its main focus is making transaction behavior explicit and safer: callers start read or write transactions separately, and deferred cleanup rolls back unfinished work. Reads can use pooled connections concurrently, while writes are serialized through a dedicated connection, so a write must be committed or rolled back before another can proceed. The library also provides helpers for scanning query results and executing statements with checks on how many rows should change, including a method that returns the row ID of an affected record.

Beyond routine queries, litesql offers tools for inspecting SQLite pragma settings, sanitizing user input for FTS5 searches, and maintaining databases through optimization, statistics updates, and vacuuming. Its snapshot feature creates point-in-time database copies using SQLite’s backup API, with controls for pacing, progress reporting, and retention of older backups. These capabilities are intended to address practical operational needs alongside database access, while leaving configuration adjustable for particular workloads.

A companion testing package opens genuine SQLite files in temporary directories rather than substituting mocks, preserving behaviors such as transactions, WAL journaling, and foreign-key enforcement. The project is distributed under the BSD-3-Clause license.

Read on github.com2 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Ggml v1.0.0

Ggml v1.0.0

ggml 1.0.0 removes deprecated public APIs and legacy DIAG_MASK operations, while adding configurable YaRN truncation and FP8 support. It also improves backend performance with quantized matrix multiplication, fused MoE operations, and new attention and scheduling paths. (github.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.

Show HN: I created a library for correctly using SQLite in Go programs · hn.today