Documentation
¶
Overview ¶
Package sqlitefile provides functions for executing SQLite statements from a file.
Index ¶
- func Exec(conn *sqlite.Conn, fsys fs.FS, filename string, opts *ExecOptions) error
- func ExecScript(conn *sqlite.Conn, fsys fs.FS, filename string, opts *ExecOptions) (err error)
- func ExecTransient(conn *sqlite.Conn, fsys fs.FS, filename string, opts *ExecOptions) error
- func PrepareTransient(conn *sqlite.Conn, fsys fs.FS, filename string) (*sqlite.Stmt, error)
- type ExecOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exec ¶
Exec executes the single statement in the given SQL file. Exec is implemented using Conn.Prepare, so subsequent calls to Exec with the same statement will reuse the cached statement object.
func ExecScript ¶
ExecScript executes a script of SQL statements from a file.
The script is wrapped in a SAVEPOINT transaction, which is rolled back on any error.
func ExecTransient ¶
ExecTransient executes the single statement in the given SQL file without caching the underlying query.
func PrepareTransient ¶
PrepareTransient prepares an SQL statement from a file that is not cached by the Conn. Subsequent calls with the same query will create new Stmts. The caller is responsible for calling Finalize on the returned Stmt when the Stmt is no longer needed.
Types ¶
type ExecOptions ¶
type ExecOptions struct {
// Args is the set of positional arguments to bind to the statement. The first
// element in the slice is ?1. See https://sqlite.org/lang_expr.html for more
// details.
Args []interface{}
// Named is the set of named arguments to bind to the statement. Keys must
// start with ':', '@', or '$'. See https://sqlite.org/lang_expr.html for more
// details.
Named map[string]interface{}
// ResultFunc is called for each result row. If ResultFunc returns an error
// then iteration ceases and Exec returns the error value.
ResultFunc func(stmt *sqlite.Stmt) error
}
ExecOptions is the set of optional arguments for the functions in this package.