sqlite

package module
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: BSD-3-Clause Imports: 10 Imported by: 11

README

go-sqlite

Go package for working with SQLite databases.

Documentation

Documentation is incomplete at this time.

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTableIfNecessary

func CreateTableIfNecessary(ctx context.Context, db Database, t Table) error

func HasTable

func HasTable(ctx context.Context, db Database, table string) (bool, error)

func HasTableWithSQLDB

func HasTableWithSQLDB(ctx context.Context, db *sql.DB, table_name string) (bool, error)

func LiveHardDieFast

func LiveHardDieFast(ctx context.Context, db Database) error

func RegisterDatabase

func RegisterDatabase(ctx context.Context, scheme string, init_func DatabaseInitializationFunc) error

RegisterDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Database` instances by the `NewDatabase` method.

func Schemes

func Schemes() []string

Schemes returns the list of schemes that have been registered.

Types

type Database

type Database interface {
	DSN(context.Context) string
	Conn(context.Context) (*sql.DB, error)
	Lock(context.Context) error
	Unlock(context.Context) error
	Close(context.Context) error
	SetLogger(context.Context, *log.Logger) error
}

func NewDatabase

func NewDatabase(ctx context.Context, uri string) (Database, error)

NewDatabase returns a new `Database` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `DatabaseInitializationFunc` function used to instantiate the new `Database`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterDatabase` method.

type DatabaseInitializationFunc

type DatabaseInitializationFunc func(ctx context.Context, uri string) (Database, error)

DatabaseInitializationFunc is a function defined by individual database package and used to create an instance of that database

type ResultRow

type ResultRow interface {
	Row() interface{}
}

type ResultSet

type ResultSet interface {
	Scan(dest ...interface{}) error
}

type ResultSetFunc

type ResultSetFunc func(row ResultSet) (ResultRow, error)

type Table

type Table interface {
	Name() string
	Schema() string
	InitializeTable(context.Context, Database) error
	IndexRecord(context.Context, Database, interface{}) error
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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