dbutil

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(db DB) error

Bootstrap creates the necessary tables for the output DB. It is safe to call on a DB that is already bootstrapped.

func Copy

func Copy(originDB DB, destDB DB, opts Options) error

Copy dumps the contents of the origin DB into the destination DB. The destination DB should be bootstrapped, but empty

func ImportFiles

func ImportFiles(originDB DB, destDB DB, opts Options, experimentID int) (success, failures int64, e error)

ImportFiles imports pairs of files from the origin to the destination DB. It copies the contents and processes the needed data (md5 hash)

func Initialize

func Initialize(db DB) error

Initialize populates the DB with default values. It is safe to call on a DB that is already initialized

Types

type DB

type DB struct {
	*sql.DB
	Driver Driver
}

DB groups a sql.DB and the driver used to initialize it

func Open

func Open(connection string, checkExisting bool) (DB, error)

Open returns a DB from the connection string. With checkExisting it will fail if the DB does not exist

func OpenSQLite

func OpenSQLite(filepath string, checkExisting bool) (DB, error)

OpenSQLite calls Open, but using a path to an SQLite file. For sintactic sugar a sqlite://path string is also accepted

func (*DB) SQLDB

func (db *DB) SQLDB() *sql.DB

SQLDB returns the *sql.DB

type Driver added in v0.0.4

type Driver int

Driver used

const (
	None Driver = iota
	Sqlite
	Postgres
)

Available drivers

type Options

type Options struct {
	Logger logrus.FieldLogger
}

Options for the ImportFiles and Copy methods. Logger is optional, if it is not provided the default stderr will be used.

Jump to

Keyboard shortcuts

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