Skip to content

eloonstra/go-sqlite3

Repository files navigation

go-sqlite3

Go Reference License: MIT

Pure Go SQLite3 driver using dynamic linking.

Warning

This driver is very early in development and should not be used in production environments. Critical features may be missing or unstable.

Features

  • No CGO required, uses dynamic linking via ebitengine/purego
  • Fully compatible with database/sql
  • Works on Linux, macOS, and Windows (untested)
  • Full support for :memory: databases

Planned Features

  • Hrana protocol support - Connect to hosted SQLite/libSQL instances
  • Custom SQL functions - Register Go functions as SQLite UDFs
  • Virtual tables - Create custom virtual table modules in Go

DSN (Data Source Name)

The driver supports various DSN formats:

Basic Format

// File path
db, err := sql.Open("sqlite3", "mydb.db")

// In-memory database
db, err := sql.Open("sqlite3", ":memory:")

DSN Parameters

Parameter Values Description
mode ro, rw, rwc, memory Database access mode (read-only, read-write, read-write-create, in-memory)
cache shared, private Cache mode for database connections
_mutex no, full Threading mode (no mutex, full mutex)
_busy_timeout milliseconds Timeout for busy handler (default: 5000ms)

Examples

// Read-only mode
db, err := sql.Open("sqlite3", "file:mydb.db?mode=ro")

// Read-write with shared cache
db, err := sql.Open("sqlite3", "file:mydb.db?mode=rw&cache=shared")

// Custom busy timeout (10 seconds)
db, err := sql.Open("sqlite3", "file:mydb.db?_busy_timeout=10000")

Requirements

  • Go 1.23 or higher
  • SQLite3 library installed on the system
    • Linux: Usually pre-installed or available via package manager
    • macOS: Pre-installed with the OS
    • Windows: May require SQLite3 DLL in PATH

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Pure Go SQLite3 driver using dynamic linking.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages