Documentation
¶
Index ¶
- Variables
- type Driver
- type MySQL
- func (m *MySQL) BeginTx(ctx context.Context, db *sql.DB, opts *sql.TxOptions) (*sql.Tx, error)
- func (m *MySQL) Close(db *sql.DB) error
- func (m *MySQL) Dialect() string
- func (m *MySQL) Open(dsn string) (*sql.DB, error)
- func (m *MySQL) Ping(ctx context.Context, db *sql.DB) error
- func (m *MySQL) Placeholder(n int) string
- type Oracle
- func (o *Oracle) BeginTx(ctx context.Context, db *sql.DB, opts *sql.TxOptions) (*sql.Tx, error)
- func (o *Oracle) Close(db *sql.DB) error
- func (o *Oracle) Dialect() string
- func (o *Oracle) Open(dsn string) (*sql.DB, error)
- func (o *Oracle) Ping(ctx context.Context, db *sql.DB) error
- func (o *Oracle) Placeholder(n int) string
- type PlaceholderFunc
- type PostgreSQL
- func (p *PostgreSQL) BeginTx(ctx context.Context, db *sql.DB, opts *sql.TxOptions) (*sql.Tx, error)
- func (p *PostgreSQL) Close(db *sql.DB) error
- func (p *PostgreSQL) Dialect() string
- func (p *PostgreSQL) Open(dsn string) (*sql.DB, error)
- func (p *PostgreSQL) Ping(ctx context.Context, db *sql.DB) error
- func (p *PostgreSQL) Placeholder(n int) string
- type SQLServer
- func (s *SQLServer) BeginTx(ctx context.Context, db *sql.DB, opts *sql.TxOptions) (*sql.Tx, error)
- func (s *SQLServer) Close(db *sql.DB) error
- func (s *SQLServer) Dialect() string
- func (s *SQLServer) Open(dsn string) (*sql.DB, error)
- func (s *SQLServer) Ping(ctx context.Context, db *sql.DB) error
- func (s *SQLServer) Placeholder(n int) string
- type SQLite
- func (s *SQLite) BeginTx(ctx context.Context, db *sql.DB, opts *sql.TxOptions) (*sql.Tx, error)
- func (s *SQLite) Close(db *sql.DB) error
- func (s *SQLite) Dialect() string
- func (s *SQLite) Open(dsn string) (*sql.DB, error)
- func (s *SQLite) Ping(ctx context.Context, db *sql.DB) error
- func (s *SQLite) Placeholder(n int) string
- type Turso
- func (t *Turso) BeginTx(ctx context.Context, db *sql.DB, opts *sql.TxOptions) (*sql.Tx, error)
- func (t *Turso) Close(db *sql.DB) error
- func (t *Turso) Dialect() string
- func (t *Turso) Open(dsn string) (*sql.DB, error)
- func (t *Turso) Ping(ctx context.Context, db *sql.DB) error
- func (t *Turso) Placeholder(n int) string
Constants ¶
This section is empty.
Variables ¶
var PlaceholderFuncs = map[string]PlaceholderFunc{
"mysql": mysqlPlaceholder,
"oracle": oraclePlaceholder,
"postgres": postgresPlaceholder,
"sqlite": sqlitePlaceholder,
"sqlserver": sqlserverPlaceholder,
"turso": sqlitePlaceholder,
}
PlaceholderFuncs contains placeholder functions for different dialects.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface {
// Open opens a connection to the database.
Open(dsn string) (*sql.DB, error)
// Close closes the database connection.
Close(db *sql.DB) error
// Ping checks if the database connection is alive.
Ping(ctx context.Context, db *sql.DB) error
// BeginTx starts a transaction with the given options.
BeginTx(ctx context.Context, db *sql.DB, opts *sql.TxOptions) (*sql.Tx, error)
// Placeholder returns the placeholder format for the driver.
Placeholder(n int) string
// Dialect returns the dialect name (mysql, postgres, sqlite, sqlserver, turso).
Dialect() string
}
Driver defines the interface for database driver implementations.
type MySQL ¶
type MySQL struct{}
MySQL implements the Driver interface for MySQL databases.
func (*MySQL) Placeholder ¶
Placeholder returns MySQL-style placeholders (?).
type Oracle ¶ added in v0.7.0
type Oracle struct{}
Oracle implements the Driver interface for Oracle databases.
func (*Oracle) BeginTx ¶ added in v0.7.0
BeginTx starts an Oracle transaction with the given options.
func (*Oracle) Placeholder ¶ added in v0.7.0
Placeholder returns Oracle-style placeholders (:1, :2, :3).
type PlaceholderFunc ¶
PlaceholderFunc is a function that generates placeholders for a given index.
func GetPlaceholderFunc ¶
func GetPlaceholderFunc(dialect string) PlaceholderFunc
GetPlaceholderFunc returns the placeholder function for the given dialect.
type PostgreSQL ¶
type PostgreSQL struct{}
PostgreSQL implements the Driver interface for PostgreSQL databases.
func NewPostgreSQL ¶
func NewPostgreSQL() *PostgreSQL
NewPostgreSQL creates a new PostgreSQL driver.
func (*PostgreSQL) Close ¶
func (p *PostgreSQL) Close(db *sql.DB) error
Close closes the PostgreSQL database connection.
func (*PostgreSQL) Dialect ¶
func (p *PostgreSQL) Dialect() string
Dialect returns the dialect name.
func (*PostgreSQL) Open ¶
func (p *PostgreSQL) Open(dsn string) (*sql.DB, error)
Open opens a connection to the PostgreSQL database.
func (*PostgreSQL) Placeholder ¶
func (p *PostgreSQL) Placeholder(n int) string
Placeholder returns PostgreSQL-style placeholders ($1, $2, $3).
type SQLServer ¶
type SQLServer struct{}
SQLServer implements the Driver interface for SQL Server databases.
func (*SQLServer) Placeholder ¶
Placeholder returns SQL Server-style placeholders (@p1, @p2, @p3).
type SQLite ¶
type SQLite struct{}
SQLite implements the Driver interface for SQLite databases.
func (*SQLite) Placeholder ¶
Placeholder returns SQLite-style placeholders (?).
type Turso ¶
type Turso struct{}
Turso implements the Driver interface for Turso databases.
func (*Turso) Placeholder ¶
Placeholder returns SQLite-style placeholders (?) since Turso uses SQLite.