common

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2013 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SBegin    = "BEGIN"
	SCommit   = "COMMIT"
	SRollback = "ROLLBACK"
)
View Source
const (
	CapCopy = iota
)

Variables

View Source
var (
	DBEXEC_VERBOSE = true
)

Functions

func FilterInclExcl

func FilterInclExcl(list []string, incl map[string]bool, excl map[string]bool) []string

Types

type Column

type Column struct {
	TableName    string
	Name         string
	Type         string
	RawType      string
	Length       int
	Null         bool
	PrimaryKey   bool
	AutoIncr     bool
	Default      interface{}
	NeedsQuoting bool

	/* how to select the column */
	Select string
}

type Config

type Config struct {
	Hostname string `yaml:"hostname,omitempty"`
	Socket   string `yaml:"socket,omitempty"`
	Port     int    `yaml:"port,omitempty"`
	Username string `yaml:"username,omitempty"`
	Password string `yaml:"password,omitempty"`
	Database string `yaml:"database,omitempty"`
	Compress bool   `yaml:"compress,omitempty"`
}

type DbExecutor

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

func NewDbExecutor

func NewDbExecutor(db *sql.DB) (*DbExecutor, error)

func (*DbExecutor) Close

func (e *DbExecutor) Close() error

warning: closes the db connection that was passed to the constructor

func (*DbExecutor) GetDb

func (e *DbExecutor) GetDb() *sql.DB

func (*DbExecutor) HasCapability

func (e *DbExecutor) HasCapability(capability int) bool

func (*DbExecutor) Multiple

func (e *DbExecutor) Multiple(name string, statements []string) []error

func (*DbExecutor) Single

func (e *DbExecutor) Single(name string, statement string) error

func (*DbExecutor) Transaction

func (e *DbExecutor) Transaction(name string, statements []string) error

type Executor

type Executor interface {
	io.Closer

	Transaction(name string, statements []string) error
	Multiple(name string, statements []string) []error
	Single(name string, statement string) error

	/* for e.g. PostgreSQL COPY support */
	HasCapability(capability int) bool

	/* will return the underlying sql.DB if it exists, otherwise nil */
	GetDb() *sql.DB
}

type FileExecutor

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

func NewFileExecutor

func NewFileExecutor(filename string) (*FileExecutor, error)

func (*FileExecutor) Close

func (e *FileExecutor) Close() error

func (*FileExecutor) GetDb

func (e *FileExecutor) GetDb() *sql.DB

func (*FileExecutor) HasCapability

func (e *FileExecutor) HasCapability(capability int) bool

func (*FileExecutor) Multiple

func (e *FileExecutor) Multiple(name string, statements []string) []error

func (*FileExecutor) Single

func (e *FileExecutor) Single(name string, statement string) error

func (*FileExecutor) Transaction

func (e *FileExecutor) Transaction(name string, statements []string) error

type Queryer

type Queryer interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

type ReadCloser

type ReadCloser interface {
	io.Closer
	Reader
}

type Reader

type Reader interface {
	Queryer

	TableNames() []string

	/* FilteredTables() is more performant than Tables() if you
	 * only need a few tables */
	Tables() []*Table
	FilteredTables(incl, excl map[string]bool) []*Table

	Read(table *Table) (*sql.Rows, error)
	CreateView(name string, body string) error
	DropView(name string) error

	CreateProjection(name string, body string, engine string, pk []string, uks [][]string) error
	DropProjection(name string) error
}

type Table

type Table struct {
	Name    string
	DbType  string /* mysql, postgres, sqlite, ... */
	Columns []*Column
}

type WriteCloser

type WriteCloser interface {
	io.Closer
	Writer
}

type Writer

type Writer interface {

	/* merge the contents of table */
	MergeTable(src *Table, dstName string, r Reader) error
}

Jump to

Keyboard shortcuts

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