1package database
2
3import (
4 "context"
5 "database/sql"
6)
7
8// DBTxConn is a thin interface for common methods that is satisfied by *sql.DB, *sql.Tx and
9// *sql.Conn.
10//
11// There is a long outstanding issue to formalize a std lib interface, but alas. See:
12// https://github.com/golang/go/issues/14468
13type DBTxConn interface {
14 ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
15 QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
16 QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
17}
18
19var (
20 _ DBTxConn = (*sql.DB)(nil)
21 _ DBTxConn = (*sql.Tx)(nil)
22 _ DBTxConn = (*sql.Conn)(nil)
23)