go-sqlite3

A self-contained CGO driver that brings SQLite3 to Go's standard database/sql interface.

Library
Go
vv1.14.50
9,230stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
86/100Excellent
Development Activity92
Maintenance72
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture86
Code Quality87
Innovation82
Learning Curve55

go-sqlite3 is the de facto CGO binding for embedding SQLite3 in Go programs. It implements the full database/sql/driver interface — Open, Exec, Query, Prepare, and Begin — so any code written against Go’s standard database/sql package can talk to a local SQLite file or in-memory database by simply importing the driver and calling sql.Open(“sqlite3”, dsn).

Rather than depending on a system-installed libsqlite3, the package vendors an amalgamated SQLite3 C source (sqlite3-binding.c/h) and compiles it directly into the Go binary via cgo, producing self-contained, reproducible builds across Linux, macOS, and Windows. Consumers who prefer to link against the system library instead can opt in with the libsqlite3 build tag.

Beyond the base driver interface, go-sqlite3 exposes SQLite-specific extension points not available through database/sql alone: registering custom Go functions and aggregates as SQL functions, collation sequences, and commit/rollback/update/authorizer/pre-update hooks. A large set of optional SQLite compile-time features — FTS5 full-text search, JSON functions, ICU, virtual tables, user authentication, serialization, and more — are each gated behind their own Go build tag, so a default build stays lean and only pulls in the C code a consumer actually asks for.

What You Get

  • database/sql driver - register once with sql.Register/blank import, then use the standard library’s sql.DB, sql.Rows, and sql.Tx APIs against SQLite exactly like any other driver.
  • Self-contained builds - the SQLite C amalgamation is vendored and compiled via cgo, so there’s no system libsqlite3 dependency by default (with an opt-in libsqlite3 build tag for linking against the system library instead).
  • Rich DSN options - dozens of SQLite PRAGMAs (journal_mode, foreign_keys, busy_timeout, synchronous, cache mode, and more) are configurable as URL query parameters on the connection string.
  • Custom SQL functions and hooks - RegisterFunc, RegisterAggregator, and RegisterCollation let Go functions run inside SQLite queries; commit, rollback, update, authorizer, and pre-update hooks expose transaction-level callbacks.
  • Build-tag-gated extensions - opt into FTS5 full-text search, JSON functions, ICU, virtual tables, user authentication, serialization, math functions, and more, each without bloating the default build.
  • Continuous fuzz testing - a dedicated CIFuzz GitHub Actions workflow fuzz-tests the CGO binding surface alongside the standard cross-platform test matrix.

Common Use Cases

  • Embedded application storage - desktop, CLI, and single-binary Go services that need a durable local database without running a separate database server.
  • Testing and local development - swapping in an in-memory or file-based SQLite database (:memory: or file::memory:?cache=shared) to run the same database/sql code paths without a Postgres/MySQL instance.
  • Edge and embedded devices - resource-constrained environments (IoT, edge compute) where a full client-server database is impractical but SQL semantics are still wanted.
  • Full-text search on local data - enabling the sqlite_fts5 build tag to index and query local text data without standing up a separate search engine.
  • Custom SQL logic via Go functions - registering domain-specific Go functions (e.g. regex matching, custom aggregates) as callable SQL functions inside queries.

Under The Hood

Architecture The package centers on sqlite3.go, which implements database/sql/driver.Driver via SQLiteDriver.Open, returning a SQLiteConn that wraps a C.sqlite3 handle and implements Exec, Query, Prepare, and Begin. CGO callback plumbing (custom functions, aggregates, hooks) lives in callback.go, using an internal handle-lookup table rather than passing Go pointers directly to C, satisfying Go’s cgo pointer-passing rules; each exported trampoline (callbackTrampoline, stepTrampoline, commitHookTrampoline, updateHookTrampoline, preUpdateHookTrampoline) resolves back to a registered Go closure. Optional SQLite compile-time features are each isolated in their own sqlite3_opt_.go file, gated by Go build tags that map directly to the corresponding C preprocessor macros, keeping the default build’s C surface area minimal while still allowing consumers to opt into fts5, icu, json, dbstat, vtable, userauth, and similar extensions individually.

Tech Stack Written in Go 1.21+ with zero external Go module dependencies (go.mod declares none beyond the standard library) and CGO_ENABLED=1 plus a working gcc toolchain as the only build requirement. Rather than linking a system libsqlite3, the package vendors an amalgamated SQLite3 C source (sqlite3-binding.c/h, prefixed to avoid gccgo build collisions) that’s compiled directly into the consuming binary; the libsqlite3 build tag switches to linking the system library instead. GitHub Actions CI (go.yaml) exercises the driver across platforms and Go versions, with dedicated workflows for releases (release.yaml), Docker-based verification (docker.yaml), and continuous fuzzing (cifuzz.yaml).

Code Quality Twenty _test.go files cover the core driver alongside dedicated tests for backups, callbacks, crypt functions, extension loading, and nearly every optional build-tag feature individually (fts3, math functions, dbstat, preupdate hooks, serialize, unlock notify, vtable, userauth), mirroring the codebase’s per-feature file layout. Errors are surfaced as typed Error, ErrNo, and ErrNoExtended values rather than opaque strings, so callers can pattern-match on specific SQLite result and extended-result codes (e.g. ErrConstraintUnique, ErrBusy) instead of parsing error text. A continuous fuzzing workflow targeting the CGO binding surface is unusually rigorous for a driver package, and Go doc comments are present throughout the exported API.

API Design The package’s core technical choice is a hand-rolled, self-contained CGO bridge to a vendored SQLite amalgamation, avoiding both a system libsqlite3 runtime dependency and the overhead of shelling out to the sqlite3 CLI, while still supporting an opt-in system-library link mode. It implements the full database/sql/driver contract plus SQLite-specific extensions (custom functions, aggregates, collations, and transaction hooks) so Go code can reach into SQLite’s C extension API without writing any C itself. Optional compile-time SQLite features map cleanly onto Go build tags on a one-feature-per-file basis, and dozens of SQLite PRAGMAs are exposed as ordinary DSN query parameters, keeping the standard library’s sql.Open idiom intact while still surfacing engine-specific tuning knobs.

Used by 21 apps in this directory

Go
86%
Apache 2.0

Authelia

Security · Authentication

28,742

OpenID Certified SSO and MFA portal for securing self-hosted web applications behind reverse proxies.

View details
91
Repo Health
81
Technical
77
Dependency
Built with
Go86%
TypeScript12%
Updated today
Go
55%
Apache 2.0

Authgear

Authentication

2,014

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
88
Repo Health
81
Technical
69
Dependency
Built with
Go55%
HTML25%
TypeScript17%
Updated 4 days ago
Go
52%
MIT

Bytebase

Devops

14,449

An open-source database CI/CD and DevSecOps platform — schema migration review, GitOps-driven changes, data masking, and access control across MySQL, PostgreSQL, Oracle, Snowflake, MongoDB, and more.

View details
91
Repo Health
73
Technical
69
Dependency
Built with
Go52%
TypeScript39%
Updated yesterday
Go
73%
Other

Convoy

Developer Tools · Devops

2,862

Convoy is an open-source, cloud-native webhooks gateway that ingests events over HTTP or straight from Kafka, SQS, Google Pub/Sub, and RabbitMQ, then reliably delivers them to subscriber endpoints with signed payloads, automatic retries, circuit breaking, and JavaScript-based transformations.

View details
89
Repo Health
81
Technical
66
Dependency
Built with
Go73%
TypeScript13%
HTML12%
Updated yesterday
Go
63%
Apache 2.0

Coroot

Analytics · Monitoring

7,895

eBPF-powered observability with AI root cause analysis — zero code changes required, full-stack visibility out of the box.

View details
88
Repo Health
80
Technical
65
Dependency
Built with
Go63%
Vue35%
Updated 3 days ago
TypeScript
98%
Other

Dokploy

Devops · Hosting Control Panel · Security

36,965

Self-hosted PaaS that deploys apps and databases on your own VPS using Docker, Traefik, and multi-build-system orchestration

View details
88
Repo Health
76
Technical
65
Dependency
Built with
TypeScript98%
Updated 2 days ago
Go
38%
MIT

ezBookkeeping

Invoicing Finance

5,494

Lightweight self-hosted personal finance manager with AI receipt scanning, multi-currency support, and MCP integration for complete data privacy.

View details
88
Repo Health
80
Technical
74
Dependency
Built with
Go38%
Vue33%
TypeScript25%
Updated yesterday
Go
86%
Apache 2.0

fabrica

AI Agents · AI Development · Devops

44

Ephemeral, VM-isolated "Agent Computers" for AI agents — a Kubernetes-native REST API backed by Kata Containers microVMs.

View details
36
Repo Health
75
Technical
81
Dependency
Built with
Go86%
Updated 1 months ago
Go
51%
MIT

Fathom Lite

Analytics

8,013

A simple, self-hosted website analytics tool built with Go and Preact that lets you understand your traffic without handing data to third parties.

View details
48
Repo Health
67
Technical
68
Dependency
Built with
Go51%
JavaScript31%
CSS15%
Updated 5 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search