sqlite

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2020 License: BSD-2-Clause Imports: 15 Imported by: 0

README

sqlite GoDoc

Helpers for using sqlite3

Tracing of sqlite execution can be enabled by using the WithTracing option, which requires using the build tags sqlite_trace or trace.

Documentation

Index

Constants

View Source
const (
	// DefaultDriver is the default driver name to be registered
	DefaultDriver = "sqlite"
)

Variables

This section is empty.

Functions

func Backup

func Backup(db *sql.DB, dest string) error

Backup backs up the open database

func Close

func Close(db *sql.DB)

Close cleans up the database before closing

func Commands

func Commands(db *sql.DB, buffer string, echo bool, w io.Writer) error

Commands emulates the client reading a series of commands

func DataVersion

func DataVersion(db *sql.DB) (int64, error)

DataVersion returns the version number of the schema

func File

func File(db *sql.DB, file string, echo bool, w io.Writer) error

File emulates ".read FILENAME"

func Filename

func Filename(db *sql.DB) string

Filename returns the filename of the DB

func Open

func Open(file string, opts ...Optional) (*sql.DB, error)

Open returns a db handler for the given file

func Opener added in v0.0.4

func Opener(opts ...Optional) func(string) (*sql.DB, error)

Opener returns func to open db handler for a given file

func Pragmas

func Pragmas(db *sql.DB, w io.Writer)

Pragmas lists all relevant Sqlite pragmas

func Version

func Version() (string, int, string)

Version returns the version of the sqlite library used libVersion string, libVersionNumber int, sourceID string) {

Types

type Config added in v0.0.3

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

Config represents the sqlite configuration options

type FuncReg

type FuncReg struct {
	Name string
	Impl interface{}
	Pure bool
}

FuncReg contains the fields necessary to register a custom Sqlite function

type Hook added in v0.0.3

type Hook func(*sqlite3.SQLiteConn) error

Hook is an SQLite connection hook

type Optional added in v0.0.3

type Optional func(*Config)

func WithDriver added in v0.0.3

func WithDriver(driver string) Optional

WithDriver sets the driver name used

func WithExists added in v0.0.3

func WithExists(fail bool) Optional

FailIfMissing will cause open to fail if file does not already exist

func WithFunctions added in v0.0.3

func WithFunctions(functions ...FuncReg) Optional

Functions registers custom functions

func WithHook added in v0.0.3

func WithHook(hook Hook) Optional

WithHook adds an sql query to execute for each new connection

func WithQuery added in v0.0.3

func WithQuery(query string) Optional

WithQuery adds an sql query to execute for each new connection

type Server

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

Server provides marshaled writes to the sqlite database

func NewServer

func NewServer(db *sql.DB) *Server

NewServer returns a server

func (*Server) Exec

func (s *Server) Exec(query string, args ...interface{}) (last int64, affected int64, err error)

Exec executes a writeable statement

func (*Server) Stream

func (s *Server) Stream(fn dbutil.StreamFunc, query string, args ...interface{}) error

Stream returns query results to the given function

Jump to

Keyboard shortcuts

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