Versions in this module Expand all Collapse all v0 v0.0.1 Sep 16, 2025 Changes in this version + func NewSQLDB(driver string, dsn string) (*sqlDB, error) + func Query(ctx context.Context, preparer Preparer, query string, parameters []any, ...) (Rows, Stmt, error) + func QueryEntities[Entity Getter](ctx context.Context, preparer Preparer, query string, parameters []any, ...) ([]Entity, error) + func QuerySingleEntity[Entity Getter](ctx context.Context, preparer Preparer, query string, parameters []any, ...) (Entity, error) + func QuerySingleValue[T any](ctx context.Context, preparer Preparer, query string, parameters []any, ...) (T, error) + func RowToAnyScalar[T any](_ context.Context, row Row, factoryFn func() T) (T, error) + func RowToEntity[T Getter](_ context.Context, row Row, factoryFn func() T) (T, error) + func RowsToAnyScalars[T any](ctx context.Context, rows Rows, factoryFn func() T) ([]T, error) + func RowsToEntities[T Getter](_ context.Context, rows Rows, factoryFn func() T) ([]T, error) + func Transaction[Result any](ctx context.Context, tx Tx, txFn TxFn[Result]) (result Result, txErr error) + type CRUDEntity interface + type ConnOpenFn func(driver string, dsn string) (DB, error) + type ConnectConfig struct + ConnMaxIdleTime time.Duration + ConnMaxLifetime time.Duration + ConnectionType string + DSNFormat string + Database string + Driver string + Host string + MaxIdleConns int + MaxOpenConns int + Parameters string + Password string + Port int + SocketDirectory string + SocketName string + User string + type DB interface + BeginTx func(ctx context.Context, opts *sql.TxOptions) (Tx, error) + Close func() error + Exec func(query string, args ...any) (Result, error) + Ping func() error + Query func(query string, args ...any) (Rows, error) + QueryRow func(query string, args ...any) Row + SetConnMaxIdleTime func(d time.Duration) + SetConnMaxLifetime func(d time.Duration) + SetMaxIdleConns func(n int) + SetMaxOpenConns func(n int) + UnderlyingDB func() *sql.DB + func Connect(cfg ConnectConfig, connOpenFn ConnOpenFn, dsn string) (DB, error) + func NewSQLDBAdapter(driver string, dsn string) (DB, error) + type ErrorChecker interface + Check func(err error) error + type Getter interface + ScanRow func(row Row) error + type Mutator interface + InsertedValues func() ([]string, []any) + type Preparer interface + Prepare func(query string) (Stmt, error) + type RealResult struct + Result sql.Result + func (r *RealResult) LastInsertId() (int64, error) + func (r *RealResult) RowsAffected() (int64, error) + type RealRow struct + func (r *RealRow) Scan(dest ...any) error + type RealRows struct + func (r *RealRows) Close() error + func (r *RealRows) Err() error + func (r *RealRows) Next() bool + func (r *RealRows) Scan(dest ...any) error + type RealStmt struct + func (s *RealStmt) Close() error + func (s *RealStmt) Exec(args ...any) (Result, error) + func (s *RealStmt) Query(args ...any) (Rows, error) + func (s *RealStmt) QueryRow(args ...any) Row + type RealTx struct + func (tx *RealTx) Commit() error + func (tx *RealTx) Exec(query string, args ...any) (Result, error) + func (tx *RealTx) Prepare(query string) (Stmt, error) + func (tx *RealTx) Rollback() error + type Result interface + LastInsertId func() (int64, error) + RowsAffected func() (int64, error) + func Exec(ctx context.Context, preparer Preparer, query string, parameters []any, ...) (Result, error) + func ExecRaw(ctx context.Context, db DB, query string, parameters []any, ...) (Result, error) + type Row interface + Err func() error + Scan func(dest ...any) error + type Rows interface + Close func() error + Err func() error + Next func() bool + Scan func(dest ...any) error + func QueryRaw(ctx context.Context, db DB, query string, parameters []any, ...) (Rows, error) + type Stmt interface + Close func() error + Exec func(args ...any) (Result, error) + Query func(args ...any) (Rows, error) + QueryRow func(args ...any) Row + type TableNamer interface + TableName func() string + type Tx interface + Commit func() error + Exec func(query string, args ...any) (Result, error) + Rollback func() error + type TxFn func(ctx context.Context, tx Tx) (Result, error)