testdb

package
v0.24.4-1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Memory = "file:test.db?cache=shared&mode=memory"

Variables

This section is empty.

Functions

func Create

func Create(name string) (ret *sql.DB)

if you run the test as "go test ... -args write" it'll write the db out in your user (home) directory

func Ins

func Ins(db tables.Executer, tablecols []string, els ...interface{}) (err error)

insert an arbitrary number of rows into the passed db. tablecols holds the names of the table and columns to query, els can hold multiple rows of data, each containing the number of cols specified by tablecols.

func Open

func Open(name, path, driver string) (ret *sql.DB)

Opens a (sqlite) database in memory or on disk, panicking on error. To create a memory table: pass "Memory" as the path. If path is empty, uses the users's home directory. If driver is empty, assumes a sqlite database. If the db/file does not already exist, it will be created.

func PathFromName

func PathFromName(name string) (ret string, err error)

from testing.T.Name() return a local db testing path

func TableCols

func TableCols(table_cols ...string) []string

given a table name, and list of column names return a super-secret helper. ( used for Ins, and WriteCsv )

func WriteCsv

func WriteCsv(db tables.Querier, w io.Writer, tablecols []string, where string) (err error)

query the passed db and write the results to w -- builds the query from "tablecols" which holds the names of the table and columns to query; "where" can filter that data. ( see also: tables.WriteCsv. )

Types

This section is empty.

Jump to

Keyboard shortcuts

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