appdb

package module
v0.0.0-...-941cfaf Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Copyright © 2021 Andrew Mobbs <andrew.mobbs@gmail.com>

Permission is hereby granted, free of charge, any person obtaining a copy of this software and associated documentation files (the "Software"), deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecBulkSql

func ExecBulkSql(db *sql.DB, sql string, values []string) error

ExecBulkSql prepares one SQL statement and executes it once for each set of values provides.

func ExecSqlStatement

func ExecSqlStatement(db *sql.DB, sql string) error

ExecSqlStatement prepares and executes one simple SQL statement and discards the result.

func InitAppDB

func InitAppDB(dbPath string, appName string, schemaVersion uint8, schema []string) (*sql.DB, error)

InitAppDB initialises a sqlite3 database at the given path, opening if it exists, creating file & path if not. dbPath -- the filesystem location of the database file appName -- name of application (arbitrary string, used to validate database) schemaVersion -- version of schema in use (8-bit integer, used to validate database) schema -- SQL statements to initialise database schema.

func Open

func Open(dbPath string, appName string, schemaVersion uint8) (*sql.DB, error)

Open opens and validates the database dbPath -- the filesystem location of the database file appName -- name of application (arbitrary string, used to validate database) schemaVersion -- version of schema in use (8-bit integer, used to validate database)

Types

type AppIdError

type AppIdError struct {
	Id         uint32
	ExpectedId uint32
}

func (*AppIdError) Error

func (e *AppIdError) Error() string

type SchemaError

type SchemaError struct {
	Statement string
	Err       error
}

func (*SchemaError) Error

func (e *SchemaError) Error() string

type SchemaVersionError

type SchemaVersionError struct {
	Version         uint8
	ExpectedVersion uint8
}

func (*SchemaVersionError) Error

func (e *SchemaVersionError) Error() string

Jump to

Keyboard shortcuts

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