Documentation ¶
Overview ¶
Package tables - utilities for working with the Tapestry sqlite tables.
Index ¶
- Constants
- func CreateBuildTime(mdlFile string) (ret *sql.DB, err error)
- func CreateIdl(idlFile string) (ret *sql.DB, err error)
- func CreateRunTime(mdlFile string) (ret *sql.DB, err error)
- func CreateTest(name string, includeRunTables bool) *sql.DB
- func Ins(db Executer, tablecols []string, els ...interface{}) (err error)
- func Insert(table string, keys ...string) string
- func InsertWith(table string, rest string, keys ...string) string
- func LoadFile(dst *sql.DB, fromFile string) (err error)
- func Must(db *sql.DB, q string, args ...any)
- func OpenModel(mdlFile string) (ret *sql.DB, err error)
- func PrintPrep(w io.Writer, err error)
- func QueryAll(db Querier, q string, cb func() error, dest ...any) (err error)
- func QueryStrings(db Querier, q string, args ...any) (ret []string, err error)
- func RowsAffected(res sql.Result) (ret int)
- func SaveFile(toFile string, force bool, src *sql.DB) (err error)
- func ScanAll(rows *sql.Rows, cb func() error, dest ...any) (err error)
- func ScanStrings(rows *sql.Rows) (ret []string, err error)
- func ShareRunTime(mdlFile string) (ret *sql.DB, err error)
- func SqliteConn(db *sql.DB, cb func(conn *sqlite3.SQLiteConn) error) (err error)
- func WriteCsv(db Querier, w io.Writer, tablecols []string, where string) (err error)
- type Cache
- func (c *Cache) Close()
- func (c *Cache) DB() *sql.DB
- func (c *Cache) Exec(q string, args ...any) (ret sql.Result, err error)
- func (c *Cache) Must(q string, args ...any)
- func (c *Cache) Query(q string, args ...any) (ret *sql.Rows, err error)
- func (c *Cache) QueryRow(q string, args ...any) (ret RowScanner)
- type Executer
- type Prep
- type Querier
- type QueryRow
- type RowScanner
Constants ¶
const ( ONE_TO_ONE = "one_one" ONE_TO_MANY = "one_any" MANY_TO_ONE = "any_one" MANY_TO_MANY = "any_any" )
cardinality
const ( USUALLY = "usually" ALWAYS = "always" SELDOM = "seldom" NEVER = "never" )
certainty
Variables ¶
This section is empty.
Functions ¶
func CreateRunTime ¶
open the model as read-only, and create a memory writable database for the runtime
func CreateTest ¶
add model and runtime to the same db if you run the test as "go test ... -args write" it'll write the db out in your user (home) directory
func Ins ¶
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 Insert ¶
Insert creates a sqlite friendly insert statement. For example: "insert into foo(col1, col2, ...) values(?, ?, ...)"
func InsertWith ¶
InsertWith allows the specification of on conflict directives
func LoadFile ¶
reads from the passed file path, overwriting the dynamic parts of the dst database. ( the dynamic portions are all in the rt schema )
func PrintPrep ¶
Prep is a utility function that prints a list of errors to w, one error per line, if the err parameter is an Prep. Otherwise it prints the err string.
func QueryAll ¶
QueryAll queries for one or more rows. For each row, it writes the row to the 'dest' args and calls 'cb' for processing.
func QueryStrings ¶
where each row is one string.
func RowsAffected ¶
func SaveFile ¶
writes the dynamic portions of the src database to the passed file path. removes the file if it created
func ScanAll ¶
ScanAll writes each row to the 'dest' args and calls 'cb' for processing. It closes rows before returning.
func ShareRunTime ¶ added in v0.24.8
reuse the model file as the runtime file ( useful sometimes for debugging )
func SqliteConn ¶
open a connection to the db and calls the passed cb. automatically closes the connection after the callback is done.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache mimics the sql.Stmt api, creating the Stmt objects on demand.
type Prep ¶
type Prep []*prepErr
Prep accumulates any errors that occur when creating a series of sql prepared statements.
func (Prep) Err ¶
Err returns an error equivalent to this error list. If the list is empty, Err returns nil.
type RowScanner ¶
RowScanner because sql.Row.Scan doesnt have the sql.Scanner.Scan interface.