sqlite

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FmtTimestampDay    = datetimes.FmtTimestampDay
	FmtTimestampHour   = datetimes.FmtTimestampHour
	FmtTimestampMinute = datetimes.FmtTimestampMinute
	FmtDateTime        = datetimes.FmtDateTime
	FmtDate            = datetimes.FmtDate
	FmtTime            = datetimes.FmtTime

	// SQLite datetime format strings
	SQLiteFmtDatetime = "%Y-%m-%d %H:%M:%S"
	SQLiteFmtMinute   = "%Y-%m-%d %H:%M"
	SQLiteFmtHour     = "%Y-%m-%d %H"
	SQLiteFmtDay      = "%Y-%m-%d"
)
View Source
const (
	ERR_UNDEFINED_DSN = "connection error: SQLite DSN '%s' is undefined\n"
)

Variables

This section is empty.

Functions

func MustConnect

func MustConnect(dsn string, opts ...Option) *sql.DB

MustConnect returns a new DB connection

func MustConnectENV

func MustConnectENV(dsn string, opts ...Option) *sql.DB

MustConnect returns a new DB connection

func ParseSQLiteDateTime

func ParseSQLiteDateTime(t string) time.Time

Types

type Option

type Option func(db *sql.DB) error

https://www.sqlite.org/pragma.html

func BusyTimeout

func BusyTimeout(milliseconds int) Option

BusyTimeout 1000 milliseconds == 1 second

func CacheSize

func CacheSize(cacheSize int) Option

CacheSize defaults to '-2000' kibibytes which is 2.048MB

func Encoding

func Encoding(charset string) Option

Encoding set the encoding of the DB; should be "UTF-8"

func JournalMode

func JournalMode(mode string) Option

JournalMode sets the journal mode for the DB, typically WAL

func MaxOpenConnections

func MaxOpenConnections(conns int) Option

MaxOpenConnections sets the max open connections. Since the SQL package handles the connection pool, it's best to set this to 1 (one) so that the SQL package essentially wraps all writes in a mutex. This will slow down writes but will help avoid a locked DB.

func PageSize

func PageSize(pageSize int) Option

PageSize the default is 4096 and is recommended

func Vacuum

func Vacuum() Option

Vacuum rebuilds the DB file to keep it tidy

func WALCheckpoint

func WALCheckpoint(mode string) Option

WalCheckpoint checkpoints the Write-Ahead-Log

Jump to

Keyboard shortcuts

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