sqlite

package
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitOrClose

func CommitOrClose(dbOrTx DBOrTx) error

func Create

func Create(dbPath string, flag int, perm os.FileMode) (*sql.DB, error)

Create makes a SQLite DB and opens it up

func CreateTemp

func CreateTemp() (db *sql.DB, deleteOrPanic func(), err error)

CreateTemp can be used to create a temporary SQLite DB. It gives you a cleanup function whose execution you can defer. The cleanup function will panic if there's an error deleting the file, since databases can contain sensitive info.

func CreateTempCopyOf

func CreateTempCopyOf(basedOn string) (db *sql.DB, path string, deleteOrPanic func(), err error)

func DeleteEmptyMessages

func DeleteEmptyMessages(ctx context.Context, dbOrTx DBOrTx) error

DeleteEmptyMessages deletes SMSes/MMSes that have no body and no attachments

func Open

func Open(dbPath string) (*sql.DB, error)

Types

type ClosableTx

type ClosableTx struct {
	DB *sql.DB
	Tx *sql.Tx
}

func NewClosableTx

func NewClosableTx(db *sql.DB) (*ClosableTx, error)

func OpenToTx

func OpenToTx(dbPath string) (*ClosableTx, error)

func (*ClosableTx) Close

func (dbAndTx *ClosableTx) Close() error

func (*ClosableTx) Commit

func (dbAndTx *ClosableTx) Commit() error

func (*ClosableTx) Exec

func (dbAndTx *ClosableTx) Exec(query string, args ...interface{}) (sql.Result, error)

func (*ClosableTx) ExecContext

func (dbAndTx *ClosableTx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*ClosableTx) Prepare

func (dbAndTx *ClosableTx) Prepare(query string) (*sql.Stmt, error)

func (*ClosableTx) PrepareContext

func (dbAndTx *ClosableTx) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)

func (*ClosableTx) Query

func (dbAndTx *ClosableTx) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*ClosableTx) QueryContext

func (dbAndTx *ClosableTx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func (*ClosableTx) QueryRow

func (dbAndTx *ClosableTx) QueryRow(query string, args ...interface{}) *sql.Row

func (*ClosableTx) QueryRowContext

func (dbAndTx *ClosableTx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

func (*ClosableTx) Rollback

func (dbAndTx *ClosableTx) Rollback() error

type DBOrTx

type DBOrTx interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

DBOrTx is an interface satisfied by *sql.DB and *sql.Tx. It lets you run whatever SQL queries you need, either in a transaction or not in a transaction

Jump to

Keyboard shortcuts

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