GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - crawshaw/sqlite: Go SQLite3 driver

BranchesTags
Open more actions menu

Latest commit

 

History

177 Commits
177 Commits

Folders and files

NameName
Last commit message
Last commit date
c
c
 
 
sqlitex
sqlitex
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
appveyor.yml
appveyor.yml
 
 
auth.go
auth.go
 
 
auth_test.go
auth_test.go
 
 
backup.go
backup.go
 
 
backup_test.go
backup_test.go
 
 
blob.go
blob.go
 
 
blob_test.go
blob_test.go
 
 
blocking_step.c
blocking_step.c
 
 
blocking_step.h
blocking_step.h
 
 
doc.go
doc.go
 
 
dummy.go
dummy.go
 
 
error.go
error.go
 
 
export_test.go
export_test.go
 
 
extension.go
extension.go
 
 
extension_test.go
extension_test.go
 
 
func.go
func.go
 
 
func_test.go
func_test.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
incrementor.go
incrementor.go
 
 
incrementor_test.go
incrementor_test.go
 
 
link.go
link.go
 
 
openflags.go
openflags.go
 
 
session.go
session.go
 
 
session_test.go
session_test.go
 
 
snapshot.go
snapshot.go
 
 
snapshot_test.go
snapshot_test.go
 
 
sqlite.go
sqlite.go
 
 
sqlite3.h
sqlite3.h
 
 
sqlite3ext.h
sqlite3ext.h
 
 
sqlite_test.go
sqlite_test.go
 
 
static.go
static.go
 
 
wrappers.c
wrappers.c
 
 
wrappers.h
wrappers.h
 
 

Repository files navigation

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.

About

Go SQLite3 driver

Topics

golangsqlite

Resources

Readme
ISC license
Activity

Stars

614 stars

Watchers

10 watching

Forks

66 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.