sqlite

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sqlite provides a SQLite3 based database configuration.

Index

Constants

View Source
const Type database.Type = "sqlite"

Type of SQLite3 database configurations.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config represents the SQLite3 database configuration.

func NewConfig

func NewConfig(file string, mode Mode, options ...ConfigSetter) *Config

NewConfig creates a new SQLite3 database configuration using the given options.

func (*Config) DSN

func (c *Config) DSN() string

DSN get the Data Source Name to be used for accessing the database.

func (*Config) DriverName

func (c *Config) DriverName() string

DriverName gets the name of the sql driver providing access to the database represented by this configuration.

func (*Config) Name added in v0.0.2

func (c *Config) Name() string

Name gets the name of the database represented by this configuration.

func (*Config) RedactedDSN

func (c *Config) RedactedDSN() string

DSN get the Data Source Name with any sensitive data redacted.

func (*Config) SchemaScripts

func (c *Config) SchemaScripts() [][]byte

SchemaScripts gets the schema updated scripts to be applied to the database during schema initialization or a schema update.

func (*Config) Type

func (c *Config) Type() database.Type

Type gets the database type represented by this configuration.

type ConfigSetter

type ConfigSetter interface {
	Apply(*Config)
}

ConfigSetter interface is used to set database configuration options during a NewConfig call.

func WithOption added in v0.0.2

func WithOption(key, value string) ConfigSetter

WithOption adds a SQLite specific option to the DSN.

func WithOptions added in v0.0.2

func WithOptions(options map[string]string) ConfigSetter

WithOptions adds SQLite specific options to the DSN.

func WithSchemaScripts

func WithSchemaScripts(scripts ...[]byte) ConfigSetter

WithSchemaScripts defines the schema update scripts to be applied during database schema update.

type ConfigSetterFunc

type ConfigSetterFunc func(*Config)

ConfigSetterFunc functions are used to set database configuration options during a NewConfig call.

func (ConfigSetterFunc) Apply

func (f ConfigSetterFunc) Apply(c *Config)

type Mode added in v0.0.2

type Mode string

SQLite3 open modes

const (
	// ModeRWC opens database for read and write operation and creates it if not yet existent.
	ModeRWC Mode = "rwc"
	// ModeRW opens database for read and write operation.
	ModeRW Mode = "rw"
	// ModeRO opens database for read operations only.
	ModeRO Mode = "ro"
	// ModeMemory opens a memory based database.
	ModeMemory Mode = "memory"
)

Jump to

Keyboard shortcuts

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