sqlite

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: BSD-2-Clause Imports: 16 Imported by: 0

README

sqlite3

Helpers for using sqlite3

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) (*sql.DB, error)

Open returns a db handler for the 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 FuncReg

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

FuncReg contains the fields necessary to register a custom Sqlite function

type Options

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

Options consolidate all sqlite options

func NewOptions

func NewOptions(file string) *Options

NewOptions returns an Options

func (*Options) Driver

func (o *Options) Driver(driver string) *Options

Driver sets the driver name used

func (*Options) FailIfMissing

func (o *Options) FailIfMissing(fail bool) *Options

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

func (*Options) Functions

func (o *Options) Functions(functions ...FuncReg) *Options

Functions registers custom functions

func (*Options) Hook

func (o *Options) Hook(hook string) *Options

Hook adds an sql query to execute for each new connection

func (*Options) Open

func (o *Options) Open() (*sql.DB, error)

Open returns a DB 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