Documentation
¶
Overview ¶
Package sqlite provides a SQLite database connection factory with sensible defaults. It uses mattn/go-sqlite3 when CGO is enabled, or modernc.org/sqlite as a pure-Go fallback, selected automatically via build tags.
Index ¶
- Constants
- func NewDB(ctx context.Context, filepath string, opts ...func(*connectionOption)) (*sql.DB, error)
- func WithConnMaxIdleTime(connMaxIdleTime int) func(*connectionOption)
- func WithConnMaxLifetime(connMaxLifetime int) func(*connectionOption)
- func WithConnMaxOpen(connMaxOpen int) func(*connectionOption)
- func WithJournalMode(journalMode string) func(*connectionOption)
- func WithMode(mode string) func(*connectionOption)
Constants ¶
View Source
const (
ENGINE = "sqlite3"
)
Variables ¶
This section is empty.
Functions ¶
func NewDB ¶
NewDB creates a new SQLite database connection with the specified options. Provide the filepath as a relative or absolute path to the database file, or use ":memory:" for an in-memory database. For example "test.db", "./my/relative/path/to/test.db", "/absolute/path/to/test.db", or ":memory:". For options, you can use the provided functions to set the connection parameters.
func WithConnMaxIdleTime ¶
func WithConnMaxIdleTime(connMaxIdleTime int) func(*connectionOption)
func WithConnMaxLifetime ¶
func WithConnMaxLifetime(connMaxLifetime int) func(*connectionOption)
func WithConnMaxOpen ¶
func WithConnMaxOpen(connMaxOpen int) func(*connectionOption)
func WithJournalMode ¶
func WithJournalMode(journalMode string) func(*connectionOption)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.