Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchResults ¶ added in v0.3.0
type BatchResults interface {
// Query returns the rows for the next queued query.
Query() (Rows, error)
// Close releases the batch results.
Close() error
}
BatchResults yields the result rows for each queued query, in order.
type BulkCopier ¶ added in v0.5.0
type BulkCopier interface {
CopyFrom(ctx context.Context, table string, columns []string, rows [][]any) (int64, error)
}
BulkCopier is an optional Driver capability: high-throughput bulk load via the native COPY protocol (e.g. pgx CopyFrom). Drivers that do not implement it fall back to multi-row INSERT. CopyFrom returns the number of rows copied.
type Driver ¶
type Driver interface {
QueryRow(ctx context.Context, sql string, args ...any) Row
Query(ctx context.Context, sql string, args ...any) (Rows, error)
Exec(ctx context.Context, sql string, args ...any) (int64, error)
Begin(ctx context.Context) (Tx, error)
BeginTx(ctx context.Context, opts TxOptions) (Tx, error)
// Ping verifies a working connection to the database, used by health probes.
Ping(ctx context.Context) error
// Stat returns a snapshot of connection-pool utilisation.
Stat() PoolStat
Close()
}
Driver abstracts database access for the drel engine.
type IsolationLevel ¶
type IsolationLevel int
IsolationLevel represents a transaction isolation level.
const ( IsoDefault IsolationLevel = iota IsoReadCommitted IsoRepeatableRead IsoSerializable )
type Pipeliner ¶ added in v0.3.0
type Pipeliner interface {
SendBatch(ctx context.Context, items []BatchItem) (BatchResults, error)
}
Pipeliner is an optional Driver capability: sending multiple queries in a single network round-trip (e.g. the pgx pipeline). Drivers that do not implement it fall back to sequential execution.
type PoolConfig ¶ added in v0.3.2
type PoolConfig struct {
MaxConns int // maximum open connections
ConnMaxLifetime time.Duration // recycle connections older than this
ConnMaxIdleTime time.Duration // close connections idle longer than this
// SimpleProtocol, when true, makes the Postgres driver use pgx's simple
// query protocol (no server-side prepared statements) for compatibility with
// PgBouncer transaction/statement pooling. Ignored by SQLite/libSQL.
SimpleProtocol bool
}
PoolConfig configures a driver's connection pool. Zero values mean "use the driver default".
type PoolStat ¶ added in v0.5.0
type PoolStat struct {
MaxConns int32 // configured maximum open connections (0 = driver default / unlimited)
AcquiredConns int32 // connections currently checked out / in use
IdleConns int32 // connections currently idle in the pool
TotalConns int32 // total connections currently held (acquired + idle + constructing)
}
PoolStat is a dialect-neutral snapshot of connection-pool utilisation, used for health/metrics endpoints. Counts come from pgxpool.Stat (Postgres) or sql.DB.Stats (SQLite/libSQL).
type Tx ¶
type Tx interface {
QueryRow(ctx context.Context, sql string, args ...any) Row
Query(ctx context.Context, sql string, args ...any) (Rows, error)
Exec(ctx context.Context, sql string, args ...any) (int64, error)
Commit(ctx context.Context) error
Rollback(ctx context.Context) error
}
Tx represents a database transaction.
type TxBulkCopier ¶ added in v0.5.0
type TxBulkCopier interface {
CopyFrom(ctx context.Context, table string, columns []string, rows [][]any) (int64, error)
}
TxBulkCopier is the transaction-scoped counterpart of BulkCopier: it lets the runtime run a COPY inside an already-open transaction so the load commits or rolls back atomically with the surrounding work. Txs that do not implement it fall back to multi-row INSERT.
type TxOptions ¶
type TxOptions struct {
Isolation IsolationLevel
ReadOnly bool
}
TxOptions configures transaction behaviour.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package libsqldriver implements driver.Driver for libSQL / Turso using the database/sql libsql driver.
|
Package libsqldriver implements driver.Driver for libSQL / Turso using the database/sql libsql driver. |