db

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

the generic database file that defines the interface

the database actions for postgres

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPostgres added in v0.5.0

func NewPostgres()

instantiate a new postgres struct

Types

type DB added in v0.5.0

type DB interface {
	// open connection to database
	Open() error

	// create database
	Create() error

	// drop database
	Drop() error

	// dump the database with the command line utility
	Dump(exe *exec.Exec) (*io.ReadCloser, error)

	// restore the database using the database driver
	Restore(reader *bufio.Reader) error

	// return the implementation type
	Impl() string

	// return the name of the database
	Name() string

	// return the filename of the dump
	DumpName() string
}

type Mysql added in v0.5.0

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

func NewMysql added in v0.5.0

func NewMysql(impl string, ip net.IPAddr, port uint16, user string, pass string, name string, maxConn int) *Mysql

instantiate a new mysql struct

func (*Mysql) Create added in v0.5.0

func (db *Mysql) Create() error

create the database

func (*Mysql) Drop added in v0.5.0

func (db *Mysql) Drop() error

drop the database

func (*Mysql) Dump added in v0.5.0

func (db *Mysql) Dump(exe *exec.Exec) (*io.ReadCloser, error)

dump the database and return the stdout stream

func (*Mysql) DumpName added in v0.5.0

func (db *Mysql) DumpName() string

return dump filename

func (*Mysql) Impl added in v0.5.0

func (db *Mysql) Impl() string

return implementation type

func (*Mysql) Name added in v0.5.0

func (db *Mysql) Name() string

return database name

func (*Mysql) Open added in v0.5.0

func (db *Mysql) Open() error

connect to database and ensure it is reachable

func (*Mysql) Restore added in v0.5.0

func (db *Mysql) Restore(reader *bufio.Reader) error

Read database dump statement by statement and fire off to the database Note: bufio.NewScanner has a line length limit of 65536 chars. db dump does only one INSERT per table Using ReadString with a ';' delimiter, ensuring that the next character after is '\n'

type Postgres added in v0.5.0

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

func (*Postgres) Create added in v0.5.0

func (db *Postgres) Create()

create the database

func (*Postgres) Drop added in v0.5.0

func (db *Postgres) Drop()

drop the database

func (*Postgres) Dump added in v0.5.0

func (db *Postgres) Dump()

dump the database and return the stdout stream

func (*Postgres) Impl added in v0.5.0

func (db *Postgres) Impl()

return implementation type

func (*Postgres) Name added in v0.5.0

func (db *Postgres) Name()

return database name

func (*Postgres) Open added in v0.5.0

func (db *Postgres) Open()

connect to database and ensure it is reachable

func (*Postgres) Restore added in v0.5.0

func (db *Postgres) Restore()

restore database

Jump to

Keyboard shortcuts

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