MyGit

crawshaw/sqlite

Fork: 61 Star: 499 (更新于 1970-01-01 00:00:00)

license: ISC

Language: C .

Go SQLite3 driver

最后发布版本: v0.2.2 ( 2020-01-24 04:04:53)

GitHub网址

Go interface to SQLite.

GoDoc Build Status (linux and macOS) Build status (windows)

This package provides a low-level Go interface to SQLite 3. Connections are pooled and if the SQLite shared cache mode is enabled the package takes advantage of the unlock-notify API to minimize the amount of handling user code needs for dealing with database lock contention.

It has interfaces for some of SQLite's more interesting extensions, such as incremental BLOB I/O and the session extension.

A utility package, sqlitex, provides some higher-level tools for making it easier to perform common tasks with SQLite. In particular it provides support to make nested transactions easy to use via sqlitex.Save.

This is not a database/sql driver.

go get -u crawshaw.io/sqlite

Example

A HTTP handler that uses a multi-threaded pool of SQLite connections via a shared cache.

var dbpool *sqlitex.Pool

func main() {
	var err error
	dbpool, err = sqlitex.Open("file:memory:?mode=memory", 0, 10)
	if err != nil {
		log.Fatal(err)
	}
	http.HandleFunc("/", handler)
	log.Fatal(http.ListenAndServe(":8080", nil))
}

func handler(w http.ResponseWriter, r *http.Request) {
	conn := dbpool.Get(r.Context())
	if conn == nil {
		return
	}
	defer dbpool.Put(conn)
	stmt := conn.Prep("SELECT foo FROM footable WHERE id = $id;")
	stmt.SetText("$id", "_user_id_")
	for {
		if hasRow, err := stmt.Step(); err != nil {
			// ... handle error
		} else if !hasRow {
			break
		}
		foo := stmt.GetText("foo")
		// ... use foo
	}
}

https://godoc.org/crawshaw.io/sqlite

Platform specific considerations

By default it requires some pthreads DLL on Windows. To avoid it, supply CGOLDFLAGS="-static" when building your application.

最近版本更新:(数据更新于 1970-01-01 00:00:00)

2020-01-24 04:04:53 v0.2.2

2018-12-20 03:16:23 v0.1.2

2018-12-20 02:51:59 v0.1.1

主题(topics):

golang, sqlite

crawshaw/sqlite同语言 C最近更新仓库

2024-10-05 22:53:22 ClemensElflein/OpenMower

2024-10-05 10:48:46 EdgeTX/edgetx

2024-10-03 03:07:35 redis/redis

2024-10-02 01:18:55 openwrt/openwrt

2024-09-24 21:54:58 netdata/netdata

2024-09-23 17:43:25 libarchive/libarchive