mirror of
https://github.com/glebarez/go-sqlite.git
synced 2025-09-27 12:12:10 +08:00
6fb1a891e19dc2cbda4c8d97cad8db2e7df86430
![dependabot[bot]](/assets/img/avatar_default.png)
Bumps [modernc.org/sqlite](https://gitlab.com/cznic/sqlite) from 1.17.0 to 1.17.1. - [Release notes](https://gitlab.com/cznic/sqlite/tags) - [Commits](https://gitlab.com/cznic/sqlite/compare/v1.17.0...v1.17.1) --- updated-dependencies: - dependency-name: modernc.org/sqlite dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
go-sqlite
This is a pure-Go SQLite driver for Golang's native database/sql package. The driver has Go-based implementation of SQLite embedded in itself (so, you don't need to install SQLite separately)
Version support:
Version | SQLite | Go 1.16 support | Go 1.17+ support |
---|---|---|---|
v1.14.8 | 3.38.0 | ✅ | ✅ |
v1.15.0 | 3.38.1 | ❌ | ✅ |
v1.15.1 | 3.38.1 | ✅ | ✅ |
v1.15.2 | 3.38.2 | ✅ | ✅ |
Usage
Example
package main
import (
"database/sql"
"log"
_ "github.com/glebarez/go-sqlite"
)
func main() {
// connect
db, err := sql.Open("sqlite", ":memory:")
if err != nil {
log.Fatal(err)
}
// get SQLite version
_ := db.QueryRow("select sqlite_version()")
}
Connection string examples
- in-memory SQLite:
":memory:"
- on-disk SQLite:
"path/to/some.db"
- Foreign-key constraint activation:
":memory:?_pragma=foreign_keys(1)"
Settings PRAGMAs in connection string
Any SQLIte pragma can be preset for a Database connection using _pragma
query parameter. Examples:
- journal mode:
path/to/some.db?_pragma=journal_mode(WAL)
- busy timeout:
:memory:?_pragma=busy_timeout(5000)
Multiple PRAGMAs can be specified, e.g.:
path/to/some.db?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL)
Languages
Go
100%