+0
日增长
9,276
stars
1,190
forks
139
watchers
619
prs
851
issues
10
releases
README
go-sqlite3
==========
Sponsors
This project is proudly sponsored by:
Latest stable version is v1.14 or later, not v2.
Description
A sqlite3 driver that conforms to the built-in database/sql interface.
Supported Golang version: See .github/workflows/go.yaml.
This package follows the official Golang Release Policy.
Overview
- go-sqlite3
- Description
- Overview
- Installation
- API Reference
- Connection String
- DSN Examples
- Features
- Usage
- Feature / Extension List
- Compilation
- Android
- ARM
- Cross Compile
- Compiling
- Linux
- Alpine
- Fedora
- Ubuntu
- macOS
- Windows
- Errors
- User Authentication
- Compile
- Usage
- Create protected database
- Password Encoding
- Available Encoders
- Restrictions
- Support
- User Management
- SQL
- Examples
- SQLiteConn
- Attached database
- Extensions
- Spatialite
- FAQ
- License
- Author
Installation
This package can be installed with the go get command:
go get github.com/mattn/go-sqlite3
_go-sqlite3_ is cgo package.
If you want to build your app using go-sqlite3, you need gcc.
Important: because this is a CGO enabled package, you are required to set the environment variable CGO_ENABLED=1 and have a gcc compiler present within your path.
API Reference
API documentation can be found here.
Examples can be found under the examples directory.
Connection String
When creating a new SQLite database or connection to an existing one, with the file name additional options can be given.
This is also known as a DSN (Data Source Name) string.
Options are append after the filename of the SQLite database.
The database filename and options are separated by an ? (Question Mark).
Options should be URL-encoded (see url.QueryEscape).
This also applies when using an in-memory database instead of a file.
Options can be given using the following format: KEYWORD=VALUE and multiple options can be combined with the & ampersand.
This library supports DSN options of SQLite itself and provides additional options.
Boolean values can be one of:
0 no false off
1 yes true on
| Name | Key | Value(s) | Description |
|------|-----|----------|-------------|
| UA - Create | _auth | - | Create User Authentication, for more information see User Authentication |
| UA - Username | _auth_user | string | Username for User Authentication, for more information see User Authentication |
| UA - Password | _auth_pass | string | Password for User Authentication, for more information see User Authentication |
| UA - Crypt | _auth_crypt | SHA1SSHA1SHA256SSHA256SHA384SSHA384SHA512SSHA512 | Password encoder to use for User Authentication, for more information see User Authentication |
| UA - Salt | _auth_salt | string | Salt to use if the configure password encoder requires a salt, for User Authentication, for more information see User Authentication |
| Auto Vacuum | _auto_vacuum \| _vacuum | 0 \| nTop issues
#607`database is locked` regression44 comments · 2018-07-12#1269DW_FORM_strx with no .debug_str_offsets section24 comments · 2024-08-08#452Does we plan to support sqlite3 encryption module21 comments · 2017-08-19#400Feature: BEGIN immediate/exclusive per transaction16 comments · 2017-03-25#1330Temporary Table Persists After Connection Closure13 comments · 2025-03-24#1248Generic PRAGMA URI parameters12 comments · 2024-06-08#994It is not possible to change driver name from sqlite3 to some another11 comments · 2022-01-06#681misuse of sqlite3_interrupt11 comments · 2019-01-06
Latest release
1.14.53 v1.14.53 2026-11-05What's Changed Fuse bind and first step into one CGO crossing by @mattn in https://github.com/mattn/go-sqlite3/pull/1455 Fuse step and column fetch into one CGO crossing in Next by @mattn in https://github.com/mattn/go-sqlite3/pull/1460 fix: release replaced authorizer callbacks by @ryanchou1994 in https://github.com/mattn/go-sqlite3/pull/1458 Return an error instead of crashing when a connection is used after Close by @mattn in https://github.com/mattn/go-sqlite3/pull/1462 Report missing arguments when Exec has no arguments by @laodouya in https://github.com/mattn/go-sqlite3/pull/1471 U