libdbexec

package
v0.0.0-...-722eec1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("libdb: not found")

	ErrTxFailed = errors.New("libdb: transaction failed")

	ErrMaxRowsReached = errors.New("max row count reached")

	ErrUniqueViolation     = errors.New("libdb: unique constraint violation")
	ErrForeignKeyViolation = errors.New("libdb: foreign key violation")
	ErrNotNullViolation    = errors.New("libdb: not null constraint violation")
	ErrCheckViolation      = errors.New("libdb: check constraint violation")
	ErrConstraintViolation = errors.New("libdb: constraint violation")

	ErrDeadlockDetected     = errors.New("libdb: deadlock detected")
	ErrSerializationFailure = errors.New("libdb: serialization failure")
	ErrLockNotAvailable     = errors.New("libdb: lock not available")
	ErrQueryCanceled        = errors.New("libdb: query canceled")

	ErrDataTruncation     = errors.New("libdb: data truncation error")
	ErrNumericOutOfRange  = errors.New("libdb: numeric value out of range")
	ErrInvalidInputSyntax = errors.New("libdb: invalid input syntax")

	ErrUndefinedColumn = errors.New("libdb: undefined column")
	ErrUndefinedTable  = errors.New("libdb: undefined table")
)
View Source
var ErrInvalidSQLiteOptions = errors.New("libdb: invalid sqlite options")

Functions

func SQLiteBusyTimeout

func SQLiteBusyTimeout(d time.Duration) *time.Duration

func SQLiteCacheKiB

func SQLiteCacheKiB(kib int) *int

func SQLiteCachePages

func SQLiteCachePages(pages int) *int

func SQLiteConns

func SQLiteConns(n int) *int

func SetupLocalInstance

func SetupLocalInstance(ctx context.Context, dbName, dbUser, dbPassword string) (string, *postgres.PostgresContainer, func(), error)

Types

type CommitTx

type CommitTx func(ctx context.Context) error

type DBManager

type DBManager interface {
	WithoutTransaction() Exec

	WithTransaction(ctx context.Context, onRollback ...func()) (Exec, CommitTx, ReleaseTx, error)

	WithTransactionOptions(ctx context.Context, opts *sql.TxOptions, onRollback ...func()) (Exec, CommitTx, ReleaseTx, error)

	Close() error
}

func NewPostgresDBManager

func NewPostgresDBManager(ctx context.Context, dsn string, schema string) (DBManager, error)

func NewSQLiteDBManager

func NewSQLiteDBManager(ctx context.Context, path string, schema string) (DBManager, error)

func NewSQLiteDBManagerWithOptions

func NewSQLiteDBManagerWithOptions(ctx context.Context, path string, schema string, opts SQLiteOptions) (DBManager, error)

type Exec

type Exec interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

	QueryRowContext(ctx context.Context, query string, args ...any) QueryRower

	DriverName() string
}

type QueryRower

type QueryRower interface {
	Scan(dest ...any) error
}

type ReleaseTx

type ReleaseTx func() error

type SQLiteJournalMode

type SQLiteJournalMode string
const (
	SQLiteJournalDefault  SQLiteJournalMode = ""
	SQLiteJournalWAL      SQLiteJournalMode = "WAL"
	SQLiteJournalDelete   SQLiteJournalMode = "DELETE"
	SQLiteJournalTruncate SQLiteJournalMode = "TRUNCATE"
	SQLiteJournalPersist  SQLiteJournalMode = "PERSIST"
	SQLiteJournalMemory   SQLiteJournalMode = "MEMORY"
	SQLiteJournalOff      SQLiteJournalMode = "OFF"
)

type SQLiteOptions

type SQLiteOptions struct {
	JournalMode SQLiteJournalMode

	TxLock SQLiteTxLock

	Synchronous SQLiteSynchronous

	BusyTimeout *time.Duration

	DisableForeignKeys bool

	CacheSize *int

	MaxOpenConns *int

	MaxIdleConns *int

	ConnMaxLifetime time.Duration

	ConnMaxIdleTime time.Duration
}

type SQLiteSynchronous

type SQLiteSynchronous string
const (
	SQLiteSynchronousDefault SQLiteSynchronous = ""
	SQLiteSynchronousOff     SQLiteSynchronous = "OFF"
	SQLiteSynchronousNormal  SQLiteSynchronous = "NORMAL"
	SQLiteSynchronousFull    SQLiteSynchronous = "FULL"
	SQLiteSynchronousExtra   SQLiteSynchronous = "EXTRA"
)

type SQLiteTxLock

type SQLiteTxLock string
const (
	SQLiteTxLockDefault   SQLiteTxLock = ""
	SQLiteTxLockImmediate SQLiteTxLock = "immediate"
	SQLiteTxLockDeferred  SQLiteTxLock = "deferred"
	SQLiteTxLockExclusive SQLiteTxLock = "exclusive"
)

Jump to

Keyboard shortcuts

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