sqlite

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Join added in v0.1.0

func Join(ss []string) string

func Quote added in v0.1.0

func Quote(s string) string

Types

type Affinity added in v0.0.15

type Affinity int

SQLite type affinity as described here https://sqlite.org/datatype3.html#type_affinity

const (
	InvalidAffinity Affinity = iota // zero value
	IntegerAffinity
	TextAffinity
	BlobAffinity
	RealAffinity
	NumericAffinity
)

func TypeAffinity added in v0.0.15

func TypeAffinity(declaredType string) Affinity

TypeAffinity implements SQLites rules for type affinity.

https://sqlite.org/datatype3.html#determination_of_column_affinity

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

DB accesses a SQLite database to read data about tables, columns, etc.

func New

func New(dsn string, typeMap TypeMap) (*DB, error)

New initializes a DB to read data from a SQLite database.

dsn is the filename of the SQLite database. typeMap is the mapping from database types to go types which should be used.

any error opening the sqlite database is returned.

func (*DB) Columns

func (d *DB) Columns(table string) ([]schema.Column, error)

Columns returns all columns of a table.

func (*DB) Foreign added in v0.0.7

func (d *DB) Foreign(table string) ([]schema.Foreign, error)

Foreign returns all foreign key constrains of a table.

func (*DB) Primary

func (d *DB) Primary(table string) ([]schema.Column, error)

Primary returns all columns of a table which form the primary key.

func (*DB) Tables

func (d *DB) Tables() ([]schema.Table, error)

Tables returns all tables found in the database.

func (*DB) Views added in v0.0.4

func (d *DB) Views() ([]schema.Table, error)

Views returns all views defined in a database.

views are returned as tables as they are identical for our purpose.

type Type added in v0.0.15

type Type struct {
	// SQLite type affinity
	Affinity Affinity

	// NOT NULL?
	NotNull bool

	// type as declared in the schema. "" for the default of this affinity.
	DeclaredType string
}

Type represents a SQLite type

type TypeMap added in v0.0.15

type TypeMap map[Type]reflect.Type

TypeMap is a mapping from SQLite-type to Go-type

Jump to

Keyboard shortcuts

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