mattn /go-sqlite3

sqlite3 driver for go using database/sql

★ 9,276⑂ 1,190👁 139⑃ 619● 851▤ 10
CMITCreated 2011-11-11mattn.github.io/go-sqlite3
下载:1.14.531.14.53 ↓1.14.532026-11-05
+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 \| n

Top issues

Latest release

1.14.53 v1.14.53 2026-11-05
What'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

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON