db

package
v0.0.0-...-918183a Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2017 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TABLE_BEANS            = "beans"
	FIELD_BEANS_ID         = "id"
	FIELD_BEANS_SERIALIZED = "serialized"
	DDL_BEANS_SQLITE       = "create table if not exists " + TABLE_BEANS + " (" + FIELD_BEANS_ID + " text  PRIMARY KEY , " + FIELD_BEANS_SERIALIZED + " BLOB)"
	DDL_BEANS_MYSQL        = "create table if not exists " + TABLE_BEANS + " (" + FIELD_BEANS_ID + " varchar(700)  PRIMARY KEY , " + FIELD_BEANS_SERIALIZED + " BLOB)"
)
View Source
const (
	BulkInsert_DefaultBatchSize = 100
)

Variables

This section is empty.

Functions

func BuildInsertStatementString

func BuildInsertStatementString(pDbType DbType, pTable string, pFields []string, pOptions InsertOptions) (string, error)

Types

type BulkManager

type BulkManager interface {
	Begin() error
	Enqueue(...interface{}) error
	Commit() error
	End() error
}

func BuildBulkManager

func BuildBulkManager(pParent *SqlInsert, pBulkOptions BulkOptions) (BulkManager, error)

func NewBulkManagerInMemory

func NewBulkManagerInMemory(pParent *SqlInsert, pBatchSize int) (BulkManager, error)

func NewBulkManagerMultiRows

func NewBulkManagerMultiRows(pParent *SqlInsert, pBatchSize int) (BulkManager, error)

type BulkManagerInMemory

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

func (*BulkManagerInMemory) Begin

func (vSelf *BulkManagerInMemory) Begin() error

func (*BulkManagerInMemory) Commit

func (vSelf *BulkManagerInMemory) Commit() error

func (*BulkManagerInMemory) End

func (vSelf *BulkManagerInMemory) End() error

func (*BulkManagerInMemory) Enqueue

func (vSelf *BulkManagerInMemory) Enqueue(pParameters ...interface{}) error

type BulkManagerMultiRows

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

func (*BulkManagerMultiRows) Begin

func (vSelf *BulkManagerMultiRows) Begin() error

func (*BulkManagerMultiRows) Commit

func (vSelf *BulkManagerMultiRows) Commit() error

func (*BulkManagerMultiRows) End

func (vSelf *BulkManagerMultiRows) End() error

func (*BulkManagerMultiRows) Enqueue

func (vSelf *BulkManagerMultiRows) Enqueue(pParameters ...interface{}) error

type BulkOptions

type BulkOptions struct {
	BatchSize   int
	BulkManager BulkManager
}

type DbHelper

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

func NewDbHelper

func NewDbHelper(pDriver string, pDataSourceName string) (*DbHelper, error)

func NewDbHelperFor

func NewDbHelperFor(pDb *sql.DB) *DbHelper

func (*DbHelper) Close

func (vSelf *DbHelper) Close() error

func (*DbHelper) CreateInsert

func (vSelf *DbHelper) CreateInsert(pTable string, pFields []string, pOptions InsertOptions) (*SqlInsert, error)

func (*DbHelper) Exec

func (vSelf *DbHelper) Exec(pQuery string, pParameters ...interface{}) (sql.Result, error)

func (*DbHelper) GetDb

func (vSelf *DbHelper) GetDb() *sql.DB

func (*DbHelper) GetDbType

func (vSelf *DbHelper) GetDbType() DbType

func (*DbHelper) LoadBean

func (vSelf *DbHelper) LoadBean(pBean IndentifiableInDb) error

func (*DbHelper) Query

func (vSelf *DbHelper) Query(pQuery string, pArgs ...interface{}) (*DbHelperRows, error)

func (*DbHelper) SaveBean

func (vSelf *DbHelper) SaveBean(pBean IndentifiableInDb) error

func (*DbHelper) SetMaxOpenConns

func (vSelf *DbHelper) SetMaxOpenConns(pNum int)

type DbHelperRows

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

func (*DbHelperRows) Close

func (vSelf *DbHelperRows) Close() error

func (*DbHelperRows) Columns

func (vSelf *DbHelperRows) Columns() ([]string, error)

func (*DbHelperRows) Err

func (vSelf *DbHelperRows) Err() error

func (*DbHelperRows) Next

func (vSelf *DbHelperRows) Next() bool

func (*DbHelperRows) Scan

func (vSelf *DbHelperRows) Scan(pDest ...interface{}) error

type DbType

type DbType string
const (
	DbType_sqlite3 DbType = "sqlite3"
	DbType_mysql   DbType = "mysql"
	DbType_unknown DbType = "unknown"
)

func GetDbType

func GetDbType(pDb *sql.DB) DbType

type IndentifiableInDb

type IndentifiableInDb interface {
	GetIdInDb() string
}

type InsertOptions

type InsertOptions struct {
	Replace                bool
	NumberOfAdditionalRows int
}

type SqlInsert

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

func (*SqlInsert) BeginBulk

func (vSelf *SqlInsert) BeginBulk(pBulkOptions BulkOptions) (bool, error)

func (*SqlInsert) Close

func (vSelf *SqlInsert) Close() error

func (*SqlInsert) Commit

func (vSelf *SqlInsert) Commit() error

func (*SqlInsert) EndBulk

func (vSelf *SqlInsert) EndBulk() error

func (*SqlInsert) Exec

func (vSelf *SqlInsert) Exec(pParameters ...interface{}) (sql.Result, error)

func (*SqlInsert) Lock

func (vSelf *SqlInsert) Lock()

func (*SqlInsert) Unlock

func (vSelf *SqlInsert) Unlock()

type SqlLiteTimestamp

type SqlLiteTimestamp []byte

func (SqlLiteTimestamp) IsNull

func (vSelf SqlLiteTimestamp) IsNull() bool

func (SqlLiteTimestamp) Time

func (vSelf SqlLiteTimestamp) Time() (time.Time, error)

Jump to

Keyboard shortcuts

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