Documentation
¶
Overview ¶
Package db owns database/sql lifecycle operations without abstracting SQL.
SQLite is available through SQLite. The libsql and go-libsql implementations live in the libsql and golibsql subpackages. Choose one libSQL implementation per executable because both upstream packages register the database/sql driver name "libsql".
Index ¶
Constants ¶
const ( DialectPostgres = "postgres" DialectSQLite = "sqlite3" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface {
Open(context.Context, Config) (*sql.DB, error)
Ping(context.Context, *sql.DB) error
}
Adapter opens a database/sql pool and provides its health check. Adapters used with DB.Migrate must also implement Dialect() string and return a supported migration dialect.
type Config ¶
type Config struct {
DSN string
MaxOpenConns int
MaxIdleConns int
ConnMaxLifetime time.Duration
ConnMaxIdleTime time.Duration
}
Config contains the connection string and database/sql pool settings.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB owns a database/sql connection pool.
func Open ¶
Open creates a database pool, applies its settings, and verifies connectivity. Callers must not pass a typed-nil adapter; only a nil interface is detected.
func (*DB) Migrate ¶
Migrate applies pending SQL migrations from migrations. The adapter must implement Dialect() string and return a supported migration dialect.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package golibsql provides an adapter for github.com/tursodatabase/go-libsql.
|
Package golibsql provides an adapter for github.com/tursodatabase/go-libsql. |
|
Package libsql provides an adapter for github.com/tursodatabase/libsql-client-go.
|
Package libsql provides an adapter for github.com/tursodatabase/libsql-client-go. |