Documentation
¶
Index ¶
- Constants
- Variables
- func FilterInclExcl(list []string, incl map[string]bool, excl map[string]bool) []string
- type Column
- type Config
- type DbExecutor
- func (e *DbExecutor) Begin(name string) error
- func (e *DbExecutor) BulkAddRecord(args ...interface{}) error
- func (e *DbExecutor) BulkFinish() error
- func (e *DbExecutor) BulkInit(table string, columns ...string) error
- func (e *DbExecutor) Close() error
- func (e *DbExecutor) Commit() error
- func (e *DbExecutor) GetDb() *sql.DB
- func (e *DbExecutor) GetTx() *sql.Tx
- func (e *DbExecutor) HasCapability(capability int) bool
- func (e *DbExecutor) Multiple(name string, statements []string) []error
- func (e *DbExecutor) Rollback() error
- func (e *DbExecutor) Single(name string, statement string) error
- func (e *DbExecutor) Submit(stmt string) error
- func (e *DbExecutor) Transaction(name string, statements []string) error
- type Executor
- type FileExecutor
- func (e *FileExecutor) Begin(name string) error
- func (e *FileExecutor) BulkAddRecord(args ...interface{}) error
- func (e *FileExecutor) BulkFinish() error
- func (e *FileExecutor) BulkInit(table string, columns ...string) error
- func (e *FileExecutor) Close() error
- func (e *FileExecutor) Commit() error
- func (e *FileExecutor) GetDb() *sql.DB
- func (e *FileExecutor) GetTx() *sql.Tx
- func (e *FileExecutor) HasCapability(capability int) bool
- func (e *FileExecutor) Multiple(name string, statements []string) []error
- func (e *FileExecutor) Single(name string, statement string) error
- func (e *FileExecutor) Submit(stmt string) error
- func (e *FileExecutor) Transaction(name string, statements []string) error
- type Queryer
- type ReadCloser
- type Reader
- type Table
- type Type
- type WriteCloser
- type Writer
Constants ¶
View Source
const ( SBegin = "BEGIN" SCommit = "COMMIT" SRollback = "ROLLBACK" )
View Source
const (
CapBulkTransfer = iota
)
Variables ¶
View Source
var ( ErrTxInProgress = errors.New("another transaction is already in progress") ErrNoTxInProgress = errors.New("no transaction is in progress") ErrCapNotSupported = errors.New("capbility not supported") )
View Source
var (
DBEXEC_VERBOSE = true
)
Functions ¶
Types ¶
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) Begin ¶ added in v0.4.1
func (e *DbExecutor) Begin(name string) error
func (*DbExecutor) BulkAddRecord ¶ added in v0.4.1
func (e *DbExecutor) BulkAddRecord(args ...interface{}) error
func (*DbExecutor) BulkFinish ¶ added in v0.4.1
func (e *DbExecutor) BulkFinish() error
func (*DbExecutor) BulkInit ¶ added in v0.4.1
func (e *DbExecutor) BulkInit(table string, columns ...string) error
func (*DbExecutor) Close ¶
func (e *DbExecutor) Close() error
warning: closes the db connection that was passed to the constructor
func (*DbExecutor) Commit ¶ added in v0.4.1
func (e *DbExecutor) Commit() error
func (*DbExecutor) GetDb ¶
func (e *DbExecutor) GetDb() *sql.DB
func (*DbExecutor) GetTx ¶ added in v0.4.1
func (e *DbExecutor) GetTx() *sql.Tx
func (*DbExecutor) HasCapability ¶
func (e *DbExecutor) HasCapability(capability int) bool
func (*DbExecutor) Multiple ¶
func (e *DbExecutor) Multiple(name string, statements []string) []error
func (*DbExecutor) Rollback ¶ added in v0.4.1
func (e *DbExecutor) Rollback() error
func (*DbExecutor) Submit ¶ added in v0.4.1
func (e *DbExecutor) Submit(stmt string) error
func (*DbExecutor) Transaction ¶
func (e *DbExecutor) Transaction(name string, statements []string) error
type Executor ¶
type Executor interface {
io.Closer
/* begin a transaction, it's an error to begin a transaction
* while another is already in progress */
Begin(name string) error
Commit() error
/* if the statement provokes an error, will automatically rollback,
* after which the transaction is no longer in progress */
Submit(stmt string) error
/* bulk statements for copying large amounts of data, the underlying
* implementation will try to use the most efficient way of achieving this,
* for example postgres' COPY FROM semantics. */
BulkInit(table string, columns ...string) error
BulkAddRecord(args ...interface{}) error
BulkFinish() error
/* submit a transaction in one go */
Transaction(name string, statements []string) error
/* submit multiple statements in one go (without a transaction) */
Multiple(name string, statements []string) []error
/* submit a single statement */
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
/* will return the underlying sql.Tx if it exists, otherwise nil */
GetTx() *sql.Tx
}
type FileExecutor ¶
type FileExecutor struct {
// contains filtered or unexported fields
}
func NewFileExecutor ¶
func NewFileExecutor(filename string) (*FileExecutor, error)
func (*FileExecutor) Begin ¶ added in v0.4.1
func (e *FileExecutor) Begin(name string) error
func (*FileExecutor) BulkAddRecord ¶ added in v0.4.1
func (e *FileExecutor) BulkAddRecord(args ...interface{}) error
func (*FileExecutor) BulkFinish ¶ added in v0.4.1
func (e *FileExecutor) BulkFinish() error
func (*FileExecutor) BulkInit ¶ added in v0.4.1
func (e *FileExecutor) BulkInit(table string, columns ...string) error
func (*FileExecutor) Close ¶
func (e *FileExecutor) Close() error
func (*FileExecutor) Commit ¶ added in v0.4.1
func (e *FileExecutor) Commit() error
func (*FileExecutor) GetDb ¶
func (e *FileExecutor) GetDb() *sql.DB
func (*FileExecutor) GetTx ¶ added in v0.4.1
func (e *FileExecutor) GetTx() *sql.Tx
func (*FileExecutor) HasCapability ¶
func (e *FileExecutor) HasCapability(capability int) bool
func (*FileExecutor) Multiple ¶
func (e *FileExecutor) Multiple(name string, statements []string) []error
func (*FileExecutor) Submit ¶ added in v0.4.1
func (e *FileExecutor) Submit(stmt string) error
func (*FileExecutor) Transaction ¶
func (e *FileExecutor) Transaction(name string, statements []string) error
type ReadCloser ¶
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 Type ¶ added in v0.4.3
type Type struct {
/* a base type, possible values:
* - text,
* - char,
* - boolean,
* - blob
* - float
* - double
* - numeric (floating point type with scale/precision)
* - integer */
Name string
/* parameters that are optionally added to base types */
Max uint
Min uint
Scale uint
Precision uint
}
func DoubleType ¶ added in v0.4.3
func DoubleType() *Type
func NumericType ¶ added in v0.4.3
type WriteCloser ¶
Click to show internal directories.
Click to hide internal directories.