Documentation
¶
Index ¶
- Variables
- func ContextWithTx(parent context.Context, v sqlex.Tx) context.Context
- func TxFromContext(parent context.Context) (sqlex.Tx, error)
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) DSN() string
- func (c *Connection) Driver() Driver
- func (c *Connection) ExecContext(ctx context.Context, query string, args ...any) (sqlex.Result, error)
- func (c *Connection) Ping() error
- func (c *Connection) QueryContext(ctx context.Context, query string, args ...any) (sqlex.Rows, error)
- func (c *Connection) Transaction(ctx context.Context, txFn func(ctx context.Context) error) error
- type DBExecutor
- type DBPinger
- type DBQuerier
- type DBTransactor
- type Driver
- type SQLDB
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNoTransaction = errors.New("no transaction")
)
View Source
var (
ErrTransactionAlreadyOpened = errors.New("transaction already opened")
)
Functions ¶
func ContextWithTx ¶ added in v1.2.0
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func New ¶
func New(dsn string) (*Connection, error)
func (*Connection) Close ¶ added in v1.2.0
func (c *Connection) Close() error
func (*Connection) Driver ¶
func (c *Connection) Driver() Driver
Driver returns the driver name used to connect to the database.
func (*Connection) ExecContext ¶
func (c *Connection) ExecContext(ctx context.Context, query string, args ...any) (sqlex.Result, error)
ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.
func (*Connection) QueryContext ¶
func (c *Connection) QueryContext(ctx context.Context, query string, args ...any) (sqlex.Rows, error)
QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.
func (*Connection) Transaction ¶
Transaction executes body in func txFn into transaction.
type DBExecutor ¶ added in v1.2.0
type DBTransactor ¶ added in v1.2.0
type SQLDB ¶ added in v1.2.0
type SQLDB interface {
DBPinger
DBQuerier
DBExecutor
DBTransactor
io.Closer
}
Click to show internal directories.
Click to hide internal directories.