Documentation
¶
Overview ¶
Package quicksqlite makes it trivial to spin-up a robust SQLite database connection with sensible production-grade defaults.
Index ¶
- Variables
- type Config
- func (c Config) Connect(ctx context.Context, dataSourceName string) (*sql.DB, error)
- func (c Config) ConnectInMemory(ctx context.Context) (*sql.DB, error)
- func (c Config) WithLogger(log *slog.Logger) Config
- func (c Config) WithMaxOpenConns(n int) Config
- func (c Config) WithMigrations(fsys fs.FS) Config
- func (c Config) WithMigrationsInPath(fsys fs.FS, path string) Config
- func (c Config) WithParamsMerged(params ...Params) Config
- type Params
Constants ¶
This section is empty.
Variables ¶
var ReadOnly = baseConfig.WithParamsMerged(Params{ "mode": []string{"ro"}, "_pragma": []string{ "query_only=true", }, })
ReadOnly is a configuration with sensible defaults for read-only connections.
var ReadWrite = baseConfig.WithMaxOpenConns(1).WithParamsMerged(Params{ "mode": []string{"rwc"}, "_txlock": []string{"immediate"}, })
ReadWrite is a configuration with sensible defaults for read-write connections.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a configuration for connecting to SQLite databases.
func (Config) Connect ¶
Connect creates a new SQLite database connection with the provided data source name.
func (Config) ConnectInMemory ¶
ConnectInMemory creates a new SQLite database in memory.
func (Config) WithLogger ¶
WithLogger sets the logger to use for database migrations.
func (Config) WithMaxOpenConns ¶
WithMaxOpenConns sets the maximum number of open connections to the database. See sql.DB.SetMaxOpenConns for the exact behavior.
func (Config) WithMigrations ¶
WithMigrations sets the file system to use for database migrations.
func (Config) WithMigrationsInPath ¶
WithMigrationsInPath sets the file system and path to use for database migrations.
func (Config) WithParamsMerged ¶
WithParamsMerged merges the provided parameters with the existing parameters.