driver

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2025 License: MIT Imports: 7 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect interface {
	Placeholder(n int) string
	QuoteIdent(ident string) string
}

Dialect defines the SQL dialect abstraction.

type Driver

type Driver struct {
	DB      *sql.DB
	Dialect Dialect
}

Driver wraps sql.DB with a dialect.

func Open

func Open(driverName, dsn string, maxOpen, maxIdle int, lifetime time.Duration) (*Driver, error)

Open initializes the DB connection with pooling configuration.

func (*Driver) Begin added in v0.0.4

func (d *Driver) Begin() (Tx, error)

Begin starts a transaction and returns the Tx.

func (*Driver) BeginTx added in v0.1.2

func (d *Driver) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)

BeginTx starts a transaction with ctx and returns the Tx.

func (*Driver) Close

func (d *Driver) Close() error

Close closes the underlying DB.

func (*Driver) Transaction

func (d *Driver) Transaction(fn func(Tx) error) error

Transaction executes fn within a transaction.

func (*Driver) TransactionContext added in v0.1.2

func (d *Driver) TransactionContext(ctx context.Context, fn func(Tx) error) error

TransactionContext executes fn within a transaction using ctx.

type MySQLDialect

type MySQLDialect struct{}

MySQLDialect implements Dialect for MySQL.

func (MySQLDialect) Placeholder

func (d MySQLDialect) Placeholder(_ int) string

func (MySQLDialect) QuoteIdent

func (d MySQLDialect) QuoteIdent(ident string) string

type PostgresDialect added in v0.1.0

type PostgresDialect struct{}

PostgresDialect implements Dialect for PostgreSQL.

func (PostgresDialect) Placeholder added in v0.1.0

func (d PostgresDialect) Placeholder(n int) string

func (PostgresDialect) QuoteIdent added in v0.1.0

func (d PostgresDialect) QuoteIdent(ident string) string

type Tx

type Tx struct{ *sql.Tx }

Tx wraps sql.Tx for transaction handling.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL