database

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDbFile

func CreateDbFile(fileName string)

func LoadConnection

func LoadConnection(databaseName string) *sqlx.DB

func RemoveDbFile

func RemoveDbFile(filePath string)

func SetupKV

func SetupKV()

Types

type Connection

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

type DbCon

type DbCon struct {
	*sqlx.DB
}

func GetDbConn

func GetDbConn(fileName string) *DbCon

func GetKvDbConn

func GetKvDbConn() *DbCon

func (*DbCon) BeginImmediateTransaction

func (db *DbCon) BeginImmediateTransaction() (*sqlx.Tx, error)

func (*DbCon) RunMigrations

func (db *DbCon) RunMigrations()

type TracedDB

type TracedDB struct {
	*sqlx.DB
}

TODO: use trace for db statements later on

func WrapDBWithTracing

func WrapDBWithTracing(db *sqlx.DB) *TracedDB

func (*TracedDB) BeginTxx

func (db *TracedDB) BeginTxx(ctx context.Context, opts interface{}) (tx *sqlx.Tx, err error)

func (*TracedDB) ExecContext

func (db *TracedDB) ExecContext(ctx context.Context, query string, args ...interface{}) (result sql.Result, err error)

func (*TracedDB) GetContext

func (db *TracedDB) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)

func (*TracedDB) NamedExecContext

func (db *TracedDB) NamedExecContext(ctx context.Context, query string, arg interface{}) (result sql.Result, err error)

func (*TracedDB) QueryContext

func (db *TracedDB) QueryContext(ctx context.Context, query string, args ...interface{}) (rows *sqlx.Rows, err error)

func (*TracedDB) QueryRowContext

func (db *TracedDB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row

func (*TracedDB) SelectContext

func (db *TracedDB) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) (err error)

SelectContext executes a select query with tracing

Jump to

Keyboard shortcuts

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