sqlite

package
v0.0.0-...-3deae0f Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SavePoint = sqlitex.Save

Functions

func GenerateInValues

func GenerateInValues(name string, n int) (string, []string)

GenerateInValues generates type safe values for IN ( ... )

func GenerateMultiLikes

func GenerateMultiLikes(field string, n int, and bool) (string, []string)

GenerateMultiLikes genrates segments of sql for using same files but with diffrent LIKE value

func RunScript

func RunScript(conn *sqlite.Conn, sql string) error

Types

type Conn

type Conn = sqlite.Conn

Reason behind this is that I don't want to import two packages that starts with sqlite into my project I can use the type alias in my project

type Database

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

Database struct which holds pool of connection

func New

func New(opt Options) (*Database, error)

New creates a sqlite database

func (*Database) Conn

func (db *Database) Conn(ctx context.Context) (conn *sqlite.Conn, done func(), err error)

Conn returns one connection from connection pool NOTE: make sure to call done function to put the connection back to the pool

type Migration

type Migration interface {
	Name() string
	Skip() bool
	Up(conn *sqlite.Conn) error
	Down(conn *sqlite.Conn) error
}

type MigrationRunner

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

func NewMigrationRunner

func NewMigrationRunner(db *Database, migrations ...Migration) (*MigrationRunner, error)

NewMigrationRunner creates a runner that facilitates up and down migration

func (*MigrationRunner) Down

func (m *MigrationRunner) Down(ctx context.Context) error

Down goes through all migration in downward direction, if any of the migration step fails, it returns an error. The whole down is protected by transaction. So all need to be success in order for down to be success

func (*MigrationRunner) Up

func (m *MigrationRunner) Up(ctx context.Context) error

Up goes through all migration in upward direction, if any of the migration step fails, it returns an error. The whole up is protected by transaction. So all need to be success in order for up to be success

type Options

type Options struct {
	StringConn string
	PoolSize   int
}

type Stmt

type Stmt = sqlite.Stmt

Jump to

Keyboard shortcuts

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