sqlite

package module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2020 License: BSD-3-Clause Imports: 11 Imported by: 1,886

README

sqlite

Package sqlite is an in-process implementation of a self-contained, serverless, zero-configuration, transactional SQL database engine. (Work In Progress)

Installation

$ go get modernc.org/sqlite

Documentation: godoc.org/modernc.org/sqlite

Documentation

Overview

Package sqlite is an in-process implementation of a self-contained, serverless, zero-configuration, transactional SQL database engine. (Work In Progress)

Changelog

2019-12-28 v1.2.0-alpha.3: Third alpha fixes issue #19.

It also bumps the minor version as the repository was wrongly already tagged with v1.1.0 before. Even though the tag was deleted there are proxies that cached that tag. Thanks /u/garaktailor for detecting the problem and suggesting this solution.

2019-12-26 v1.1.0-alpha.2: Second alpha release adds support for accessing a database concurrently by multiple goroutines and/or processes. v1.1.0 is now considered feature-complete. Next planed release should be a beta with a proper test suite.

2019-12-18 v1.1.0-alpha.1: First alpha release using the new cc/v3, gocc, qbe toolchain. Some primitive tests pass on linux_{amd64,386}. Not yet safe for concurrent access by multiple goroutines. Next alpha release is planed to arrive before the end of this year.

2017-06-10 Windows/Intel no more uses the VM (thanks Steffen Butzer).

2017-06-05 Linux/Intel no more uses the VM (cznic/virtual).

Connecting to a database

To access a Sqlite database do something like

import (
	"database/sql"

	_ "modernc.org/sqlite"
)

...

db, err := sql.Open("sqlite", dsnURI)

...

Do not use in production

Supported platforms and architectures

linux	386
linux	amd64

Planned platforms and architectures

linux	arm
linux	arm64
windows	386
windows	amd64

Sqlite documentation

See https://sqlite.org/docs.html

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorCodeString maps Error.Code() to its string representation.
	ErrorCodeString = map[int]string{
		bin.DSQLITE_ABORT:             "Callback routine requested an abort (SQLITE_ABORT)",
		bin.DSQLITE_AUTH:              "Authorization denied (SQLITE_AUTH)",
		bin.DSQLITE_BUSY:              "The database file is locked (SQLITE_BUSY)",
		bin.DSQLITE_CANTOPEN:          "Unable to open the database file (SQLITE_CANTOPEN)",
		bin.DSQLITE_CONSTRAINT:        "Abort due to constraint violation (SQLITE_CONSTRAINT)",
		bin.DSQLITE_CORRUPT:           "The database disk image is malformed (SQLITE_CORRUPT)",
		bin.DSQLITE_DONE:              "sqlite3_step() has finished executing (SQLITE_DONE)",
		bin.DSQLITE_EMPTY:             "Internal use only (SQLITE_EMPTY)",
		bin.DSQLITE_ERROR:             "Generic error (SQLITE_ERROR)",
		bin.DSQLITE_FORMAT:            "Not used (SQLITE_FORMAT)",
		bin.DSQLITE_FULL:              "Insertion failed because database is full (SQLITE_FULL)",
		bin.DSQLITE_INTERNAL:          "Internal logic error in SQLite (SQLITE_INTERNAL)",
		bin.DSQLITE_INTERRUPT:         "Operation terminated by sqlite3_interrupt()(SQLITE_INTERRUPT)",
		bin.DSQLITE_IOERR | (1 << 8):  "(SQLITE_IOERR_READ)",
		bin.DSQLITE_IOERR | (10 << 8): "(SQLITE_IOERR_DELETE)",
		bin.DSQLITE_IOERR | (11 << 8): "(SQLITE_IOERR_BLOCKED)",
		bin.DSQLITE_IOERR | (12 << 8): "(SQLITE_IOERR_NOMEM)",
		bin.DSQLITE_IOERR | (13 << 8): "(SQLITE_IOERR_ACCESS)",
		bin.DSQLITE_IOERR | (14 << 8): "(SQLITE_IOERR_CHECKRESERVEDLOCK)",
		bin.DSQLITE_IOERR | (15 << 8): "(SQLITE_IOERR_LOCK)",
		bin.DSQLITE_IOERR | (16 << 8): "(SQLITE_IOERR_CLOSE)",
		bin.DSQLITE_IOERR | (17 << 8): "(SQLITE_IOERR_DIR_CLOSE)",
		bin.DSQLITE_IOERR | (2 << 8):  "(SQLITE_IOERR_SHORT_READ)",
		bin.DSQLITE_IOERR | (3 << 8):  "(SQLITE_IOERR_WRITE)",
		bin.DSQLITE_IOERR | (4 << 8):  "(SQLITE_IOERR_FSYNC)",
		bin.DSQLITE_IOERR | (5 << 8):  "(SQLITE_IOERR_DIR_FSYNC)",
		bin.DSQLITE_IOERR | (6 << 8):  "(SQLITE_IOERR_TRUNCATE)",
		bin.DSQLITE_IOERR | (7 << 8):  "(SQLITE_IOERR_FSTAT)",
		bin.DSQLITE_IOERR | (8 << 8):  "(SQLITE_IOERR_UNLOCK)",
		bin.DSQLITE_IOERR | (9 << 8):  "(SQLITE_IOERR_RDLOCK)",
		bin.DSQLITE_IOERR:             "Some kind of disk I/O error occurred (SQLITE_IOERR)",
		bin.DSQLITE_LOCKED | (1 << 8): "(SQLITE_LOCKED_SHAREDCACHE)",
		bin.DSQLITE_LOCKED:            "A table in the database is locked (SQLITE_LOCKED)",
		bin.DSQLITE_MISMATCH:          "Data type mismatch (SQLITE_MISMATCH)",
		bin.DSQLITE_MISUSE:            "Library used incorrectly (SQLITE_MISUSE)",
		bin.DSQLITE_NOLFS:             "Uses OS features not supported on host (SQLITE_NOLFS)",
		bin.DSQLITE_NOMEM:             "A malloc() failed (SQLITE_NOMEM)",
		bin.DSQLITE_NOTADB:            "File opened that is not a database file (SQLITE_NOTADB)",
		bin.DSQLITE_NOTFOUND:          "Unknown opcode in sqlite3_file_control() (SQLITE_NOTFOUND)",
		bin.DSQLITE_NOTICE:            "Notifications from sqlite3_log() (SQLITE_NOTICE)",
		bin.DSQLITE_PERM:              "Access permission denied (SQLITE_PERM)",
		bin.DSQLITE_PROTOCOL:          "Database lock protocol error (SQLITE_PROTOCOL)",
		bin.DSQLITE_RANGE:             "2nd parameter to sqlite3_bind out of range (SQLITE_RANGE)",
		bin.DSQLITE_READONLY:          "Attempt to write a readonly database (SQLITE_READONLY)",
		bin.DSQLITE_ROW:               "sqlite3_step() has another row ready (SQLITE_ROW)",
		bin.DSQLITE_SCHEMA:            "The database schema changed (SQLITE_SCHEMA)",
		bin.DSQLITE_TOOBIG:            "String or BLOB exceeds size limit (SQLITE_TOOBIG)",
		bin.DSQLITE_WARNING:           "Warnings from sqlite3_log() (SQLITE_WARNING)",
	}
)

Functions

This section is empty.

Types

type Driver

type Driver struct{}

Driver implements database/sql/driver.Driver.

func (*Driver) Open

func (d *Driver) Open(name string) (driver.Conn, error)

Open returns a new connection to the database. The name is a string in a driver-specific format.

Open may return a cached connection (one previously closed), but doing so is unnecessary; the sql package maintains a pool of idle connections for efficient re-use.

The returned connection is only used by one goroutine at a time.

type Error added in v1.3.0

type Error struct {
	// contains filtered or unexported fields
}

Error represents sqlite library error code.

func (*Error) Code added in v1.3.0

func (e *Error) Code() int

Code returns the sqlite result code for this error.

func (*Error) Error added in v1.3.0

func (e *Error) Error() string

Error implements error.

Directories

Path Synopsis
benchmark module
internal
bin

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL