mirror of
https://github.com/glebarez/go-sqlite.git
synced 2025-09-27 04:06:00 +08:00
d52e825e90e75f2f2cc78822510db53bbd2fed64
![dependabot[bot]](/assets/img/avatar_default.png)
Bumps [schneegans/dynamic-badges-action](https://github.com/schneegans/dynamic-badges-action) from 1.6.0 to 1.7.0. - [Release notes](https://github.com/schneegans/dynamic-badges-action/releases) - [Changelog](https://github.com/Schneegans/dynamic-badges-action/blob/master/changelog.md) - [Commits](https://github.com/schneegans/dynamic-badges-action/compare/v1.6.0...v1.7.0) --- updated-dependencies: - dependency-name: schneegans/dynamic-badges-action dependency-type: direct:production update-type: version-update:semver-minor ... 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)
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%