whatisgithub

What is go-sqlite3?

mattn/go-sqlite3 — explained in plain English

Analysis updated 2026-06-24

9,095CAudience · developerComplexity · 2/5Setup · moderate

In one sentence

A Go library that connects Go's standard database interface to SQLite, letting your Go programs store and query data in a lightweight single-file database without running a separate server.

Mindmap

mindmap
  root((go-sqlite3))
    What it does
      SQLite in Go
      Standard DB interface
      File-based storage
    Features
      Connection options
      Custom functions
      Auth extension
      Hook callbacks
    Requirements
      Go runtime
      C compiler
    Use cases
      Local app storage
      Embedded database
      CLI tools
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add a lightweight local database to a Go application without running a separate database server.

USE CASE 2

Register custom Go functions callable from SQL queries inside a SQLite database.

USE CASE 3

Enable WAL mode and foreign key constraints via connection string options in a Go app.

USE CASE 4

Protect a SQLite database file with a username and password using the bundled user authentication extension.

What is it built with?

GoCSQLite

How does it compare?

mattn/go-sqlite3meetecho/janus-gatewayfreebsd/freebsd-src
Stars9,0959,0889,074
LanguageCCC
Setup difficultymoderatehardhard
Complexity2/54/55/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires a C compiler (GCC or Clang) at build time, Windows users need extra setup to get a working C toolchain.

So what is it?

go-sqlite3 is a library that lets Go programs store and query data using SQLite, a lightweight database that lives in a single file on disk. Go has a standard interface for talking to databases, and this library connects that interface to SQLite so you can use the same code patterns you would use with any other database, just pointed at a local file instead of a server. Because SQLite is written in C, this library wraps the C code and calls it from Go. That means you need a C compiler installed on your machine when you build any Go application that uses go-sqlite3. The README notes this clearly as a requirement. On most Linux systems and macOS the compiler is already available, on Windows it requires a bit more setup. When you open a database connection you can pass a connection string with options that control how SQLite behaves. These options cover things like whether foreign key constraints are enforced, how the database handles write-ahead logging (a setting that affects performance and crash recovery), whether the database is opened in read-only mode, timeout behavior when multiple processes try to write at the same time, and time zone handling for date values. The library also supports user authentication, which is an optional SQLite extension that lets you protect a database file with a username and password. Passwords can be stored using several hashing algorithms. There is additional support for custom Go functions that you can register and then call from SQL queries, for callback hooks that fire when rows are inserted, updated, or deleted, and for loading additional SQLite extensions. The project includes an examples directory, follows the official Go release support policy, and has documentation on cross-compiling for different platforms including Android and ARM devices.

Copy-paste prompts

Prompt 1
Using go-sqlite3, write a Go program that opens a SQLite database file, creates a table, inserts a row, and queries it back.
Prompt 2
Show me how to register a custom Go function with go-sqlite3 so I can call it from inside a SQL query.
Prompt 3
In go-sqlite3, how do I enable WAL mode and enforce foreign key constraints when opening a connection?
Prompt 4
How do I set up go-sqlite3 with user authentication so the database file requires a password to open?

Frequently asked questions

What is go-sqlite3?

A Go library that connects Go's standard database interface to SQLite, letting your Go programs store and query data in a lightweight single-file database without running a separate server.

What language is go-sqlite3 written in?

Mainly C. The stack also includes Go, C, SQLite.

How hard is go-sqlite3 to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is go-sqlite3 for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.