db

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package db exposes a lightweight abstraction over the SQLite code. It performs some basic mapping of lower-level types to rqlite types.

Index

Constants

This section is empty.

Variables

View Source
var DBVersion string

Functions

This section is empty.

Types

type Config

type Config struct {
	DSN    string // Datasource name
	Memory bool   // In-memory database enabled?
}

Config represents the configuration of the SQLite database.

func NewConfig

func NewConfig() *Config

NewConfig returns an instance of Config for the database at path.

func (*Config) FQDSN

func (c *Config) FQDSN(path string) string

FQDSN returns the fully-qualified datasource name.

type DB

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

DB is the SQL database.

func Open

func Open(dbPath string) (*DB, error)

Open an existing database, creating it if it does not exist.

func OpenWithConfiguration

func OpenWithConfiguration(dbPath string, conf *Config) (*DB, error)

OpenWithConfiguration an existing database, creating it if it does not exist.

func (*DB) Backup

func (db *DB) Backup(path string) error

Backup writes a consistent snapshot of the database to the given file.

func (*DB) Close

func (db *DB) Close() error

Close closes the underlying database connection.

func (*DB) Execute

func (db *DB) Execute(queries []string, tx, xTime bool) ([]*Result, error)

Execute executes queries that modify the database.

func (*DB) Query

func (db *DB) Query(queries []string, tx, xTime bool) ([]*Rows, error)

Query executes queries that return rows, but don't modify the database.

type Result

type Result struct {
	LastInsertID int64   `json:"last_insert_id,omitempty"`
	RowsAffected int64   `json:"rows_affected,omitempty"`
	Error        string  `json:"error,omitempty"`
	Time         float64 `json:"time,omitempty"`
}

Result represents the outcome of an operation that changes rows.

type Rows

type Rows struct {
	Columns []string        `json:"columns,omitempty"`
	Types   []string        `json:"types,omitempty"`
	Values  [][]interface{} `json:"values,omitempty"`
	Error   string          `json:"error,omitempty"`
	Time    float64         `json:"time,omitempty"`
}

Rows represents the outcome of an operation that returns query data.

Jump to

Keyboard shortcuts

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