Documentation
¶
Overview ¶
Package sql provides a database/sql wrapper.
Package sql provides a database/sql wrapper.
Index ¶
- Constants
- Variables
- func ErrCode(err error) string
- func IsAdminShutdown(err error) bool
- func IsRetryable(err error) bool
- type DB
- func (db *DB) BeginTx(ctx context.Context, opts *TxOptions) (*Tx, error)
- func (db *DB) Close() error
- func (db *DB) Exec(ctx context.Context, query string, args ...any) (Result, error)
- func (db *DB) Ping(ctx context.Context) error
- func (db *DB) Query(ctx context.Context, query string, args ...any) (*Rows, error)
- func (db *DB) QueryRow(ctx context.Context, query string, args ...any) *Row
- func (db *DB) Tx(ctx context.Context, opts *TxOptions, fn func(tx *Tx) error) error
- type Func
- type MiddlewareFunc
- type NullString
- type Option
- type Options
- type Result
- type Row
- type Rows
- type Tx
- type TxOptions
Constants ¶
View Source
const ( DefaultReconnectRetries = 5 DefaultTxRetries = 10 )
Variables ¶
View Source
var (
ErrNoRows = sql.ErrNoRows
)
Functions ¶
func IsAdminShutdown ¶
func IsRetryable ¶
Types ¶
type DB ¶
DB is a simple wrapper of sql.db.
func Open ¶
Open opens a database specified by its database driver name and a driver-specific connect url.
type MiddlewareFunc ¶
MiddlewareFunc is a function that receives a Func and returns a Func.
type NullString ¶
type NullString = sql.NullString
type Option ¶
type Option interface {
Apply(*Options)
}
Option provides options for the creation of a db connection.
func WithReconnect ¶
WithReconnect will configure the db connection to reconnect if the connection has been closed due to an admin shutdown.
func WithTxRetries ¶
WithTxRetries will configure the db to retry failed transactions.
Click to show internal directories.
Click to hide internal directories.