driver

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 4 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(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) 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.

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 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