koans

package
v0.0.0-...-709911c Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PragmaEncoding     = "PRAGMA encoding;"
	PragmaEncodingStmt = "PRAGMA encoding = '%s';"
	UTF8               = "UTF-8"
)
View Source
const (
	PragmaForeignKeys     = "PRAGMA foreign_keys;"
	PragmaForeignKeysStmt = "PRAGMA foreign_keys = ON;"
)
View Source
const (
	PragmaJournalMode = "PRAGMA journal_mode;"
	JournalModeDelete = "DELETE"
	JournalModeWAL    = "WAL"
)
View Source
const (
	DbPrefix      = "file:"
	DbName        = "koans.db"
	BackupDbName  = "koans-backup.db"
	DbFile        = DbPrefix + DbName
	DbBackupFile  = DbPrefix + BackupDbName
	DbFileShm     = DbFile + "-shm"
	DbFileWal     = DbFile + "-wal"
	SqliteCmd     = "sqlite3"
	SqliteSchema  = "main"
	SqliteConnErr = "failed to open db connection to %s"
)
View Source
const (
	PragmaTableList  = "PRAGMA main.table_list;"
	UpsertRecordStmt = `
	INSERT INTO %s(id, name) VALUES(?, ?)
	ON CONFLICT DO
		UPDATE SET updated=datetime('unixepoch');`
)
View Source
const (
	// STRICT must be appended to every CREATE TABLE
	// https://www.sqlite.org/stricttables.html
	// WITHOUT ROWID avoids null primary keys (CHECK needed for empty strings)
	// https://www.sqlite.org/withoutrowid.html
	TableTestWithoutRowIdStrict       = "test_without_rowid_strict"
	CreateStrictWithoutRowIdTableStmt = `` /* 237-byte string literal not displayed */

)
View Source
const (
	// STRICT must be appended to every CREATE TABLE
	// https://www.sqlite.org/stricttables.html
	TableTestStrict       = "test_strict"
	CreateStrictTableStmt = `` /* 196-byte string literal not displayed */

)
View Source
const (
	PragmaSynchronous       = "PRAGMA synchronous;"
	PragmaSynchronousFull   = "FULL"
	PragmaSynchronousNormal = "NORMAL"
)
View Source
const (
	PragmaTimeoutMs   = 5000
	PragmaTimeoutStmt = "PRAGMA busy_timeout = %d;"
	PragmaTimeout     = "PRAGMA busy_timeout;"
)

Variables

Functions

func BackupDbUrl

func BackupDbUrl() (string, error)

BackupDBUrl - construct a Sqlite DSN (Data Source Name) string as a backup target https://www.sqlite.org/backup.html

func DbUrl

func DbUrl() (string, error)

DbUrl - construct a Sqlite DSN (Data Source Name) string https://github.com/mattn/go-sqlite3#connection-string

func Setup

func Setup(dbUrl string) (*sql.DB, error)

func Teardown

func Teardown(t *testing.T) error

Types

type Koans

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

func New

func New() (*Koans, error)

func (*Koans) Backup

func (k *Koans) Backup() error

Backup - backup WAL mode SQLite DB https://github.com/mattn/go-sqlite3/blob/master/_example/hook/hook.go

type KoansTest

type KoansTest struct {
	Koans
}

func SetupSuite

func SetupSuite() (*KoansTest, func(t *testing.T) error, error)

func (*KoansTest) InsertRecords

func (k *KoansTest) InsertRecords(b *testing.B) error

func (*KoansTest) Truncate

func (k *KoansTest) Truncate() error

func (*KoansTest) UpsertRecord

func (k *KoansTest) UpsertRecord(b *testing.B) error

type TableListRaw

type TableListRaw struct {
	// schema: the schema in which the table or view appears (for example "main" or "temp").
	Schema string
	// name: the name of the table or view.
	Name string
	// type: the type of object - one of "table", "view", "shadow" (for shadow tables), or "virtual" for virtual tables.
	Type string
	// ncol: the number of columns in the table, including generated columns and hidden columns.
	NCol int
	// wr: 1 if the table is a WITHOUT ROWID table or 0 if is not.
	WR int
	// strict: 1 if the table is a STRICT table or 0 if it is not.
	Strict int
}

func (*TableListRaw) Skip

func (t *TableListRaw) Skip() bool

omit SQLite internal tables kv: schema.name -> skip == true

func (*TableListRaw) TableName

func (t *TableListRaw) TableName() string

Jump to

Keyboard shortcuts

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