Documentation ¶
Index ¶
- func DbFormatColDelimSettings(coldelim ...string) (readsettings map[string]string)
- func OutputResultSet(w io.Writer, name string, contentext string, res *DbResultSet, err error, ...)
- func RegisterDbReadFormat(formatname string, settings map[string]string, ...)
- type ColumnType
- func (colType *ColumnType) DatabaseType() string
- func (colType *ColumnType) HasLength() bool
- func (colType *ColumnType) HasNullable() bool
- func (colType *ColumnType) HasPrecisionScale() bool
- func (colType *ColumnType) Length() int64
- func (colType *ColumnType) Name() string
- func (colType *ColumnType) Nullable() bool
- func (colType *ColumnType) Numeric() bool
- func (colType *ColumnType) Precision() int64
- func (colType *ColumnType) Scale() int64
- func (colType *ColumnType) Type() reflect.Type
- type DBExecuted
- type DBQuery
- func (dbqry *DBQuery) Data() []interface{}
- func (dbqry *DBQuery) MetaData() *DbResultSetMetaData
- func (dbqry *DBQuery) Next() bool
- func (dbqry *DBQuery) PrintResult(out *goio.IORW, name string, contentext string, setting ...string)
- func (dbqry *DBQuery) Process() (err error)
- func (dbqry *DBQuery) ReadAll(w io.Writer, format string)
- func (dbqry *DBQuery) ReadAllCustom(w io.Writer, settings map[string]string, ...)
- type DbConnection
- func (cn *DbConnection) Execute(query string, args ...interface{}) (lastInsertID int64, rowsAffected int64, err error)
- func (cn *DbConnection) ParseQuery(query string) (parsedquery string, params []string)
- func (cn *DbConnection) Query(query string, args ...interface{}) (rset *DbResultSet, err error)
- type DbManager
- func (dbmngr *DbManager) Connection(alias string) (cn *DbConnection)
- func (dbmngr *DbManager) Execute(alias string, query string, args ...interface{}) (dbexecuted *DBExecuted)
- func (dbmngr *DbManager) Open(alias string, driver string, datasourcename string) (cn *DbConnection, err error)
- func (dbmngr *DbManager) Query(alias string, query string, args ...interface{}) (dbquery *DBQuery)
- func (dbmngr *DbManager) RegisterConnection(alias string, driver string, datasourcename string) (err error)
- type DbResultSet
- type DbResultSetMetaData
- type DbStatement
- func (stmnt *DbStatement) Begin() (err error)
- func (stmnt *DbStatement) Close() (err error)
- func (stmnt *DbStatement) Execute(query string, args ...interface{}) (lastInsertID int64, rowsAffected int64, err error)
- func (stmnt *DbStatement) Query(query string, args ...interface{}) (rset *DbResultSet, err error)
- type ProcessingFunc
- type QueryStage
- type ReadColumnsFunc
- type ReadRowFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DbFormatColDelimSettings ¶
DbFormatColDelimSettings DbFormatColDelimSettings
func OutputResultSet ¶
func OutputResultSet(w io.Writer, name string, contentext string, res *DbResultSet, err error, setting ...string)
OutputResultSet - helper method that output res *DbResultSet to the following formats into a io.Writer contentext=.js => javascript contentext=.json => json contentext=.csv => .csv
Types ¶
type ColumnType ¶
type ColumnType struct {
// contains filtered or unexported fields
}
ColumnType structure defining column definition
func (*ColumnType) DatabaseType ¶
func (colType *ColumnType) DatabaseType() string
DatabaseType ColumnType underlying db type as defined by cnstring of DbConnection
func (*ColumnType) HasLength ¶
func (colType *ColumnType) HasLength() bool
HasLength ColumnType content has Length definition
func (*ColumnType) HasNullable ¶
func (colType *ColumnType) HasNullable() bool
HasNullable ColumnType content has NULL able content
func (*ColumnType) HasPrecisionScale ¶
func (colType *ColumnType) HasPrecisionScale() bool
HasPrecisionScale ColumnType content has PrecisionScale
func (*ColumnType) Length ¶
func (colType *ColumnType) Length() int64
Length ColumnType content lenth must be used in conjunction with HasLength
func (*ColumnType) Nullable ¶
func (colType *ColumnType) Nullable() bool
Nullable ColumnType content is Nullable
func (*ColumnType) Numeric ¶
func (colType *ColumnType) Numeric() bool
Numeric ColumnType is Numeric() bool
func (*ColumnType) Precision ¶
func (colType *ColumnType) Precision() int64
Precision ColumnType numeric Precision. Used in conjunction with HasPrecisionScale
func (*ColumnType) Scale ¶
func (colType *ColumnType) Scale() int64
Scale ColumnType Scale. Used in conjunction with HasPrecisionScale
func (*ColumnType) Type ¶
func (colType *ColumnType) Type() reflect.Type
Type ColumnType reflect.Type as specified by golang sql/database
type DBExecuted ¶
DBExecuted controller
type DBQuery ¶
type DBQuery struct { RSet *DbResultSet Err error // contains filtered or unexported fields }
DBQuery DBQuery controller
func (*DBQuery) Data ¶
func (dbqry *DBQuery) Data() []interface{}
Data returns an array if data of the current row from the underlying resultset
func (*DBQuery) MetaData ¶
func (dbqry *DBQuery) MetaData() *DbResultSetMetaData
MetaData return a DbResultSetMetaData object of the resultset that is wrapped by this DBQuery controller
func (*DBQuery) PrintResult ¶
func (dbqry *DBQuery) PrintResult(out *goio.IORW, name string, contentext string, setting ...string)
PrintResult [refer to OutputResultSet] - helper method that output res *DbResultSet to the following formats into a io.Writer contentext=.js => javascript contentext=.json => json contentext=.csv => .csv
type DbConnection ¶
type DbConnection struct {
// contains filtered or unexported fields
}
DbConnection DbConnection controller
func (*DbConnection) Execute ¶
func (cn *DbConnection) Execute(query string, args ...interface{}) (lastInsertID int64, rowsAffected int64, err error)
Execute - Execute (query) refer to golang sql connection Execute method
func (*DbConnection) ParseQuery ¶
func (cn *DbConnection) ParseQuery(query string) (parsedquery string, params []string)
ParseQuery parse query and return parsed query based on db connection type and list of paramnames query e.g 'SELECT :TEST-PARAM AS param' where :TEST-PARAM is name of parameter
func (*DbConnection) Query ¶
func (cn *DbConnection) Query(query string, args ...interface{}) (rset *DbResultSet, err error)
Query - Query (query) refer to golang sql connection Query method except that it returns and DbResultSet that extends standard resultset functionality
type DbManager ¶
type DbManager struct {
// contains filtered or unexported fields
}
DbManager DbManager controller
func DatabaseManager ¶
func DatabaseManager() *DbManager
DatabaseManager global instance of DbManager
func (*DbManager) Connection ¶
func (dbmngr *DbManager) Connection(alias string) (cn *DbConnection)
Connection returns aliased DbConnection
func (*DbManager) Execute ¶
func (dbmngr *DbManager) Execute(alias string, query string, args ...interface{}) (dbexecuted *DBExecuted)
Execute execute query for alias connection return a DbExecute controller that represents the outcome of the executed request
func (*DbManager) Open ¶
func (dbmngr *DbManager) Open(alias string, driver string, datasourcename string) (cn *DbConnection, err error)
Open - open a db connection based and register aliased reference to it in the DbManager returns a DbConnnection controller of the connection
type DbResultSet ¶
type DbResultSet struct {
// contains filtered or unexported fields
}
DbResultSet DbResultSet container
func (*DbResultSet) Close ¶
func (rset *DbResultSet) Close() (err error)
Close the DbResultSet as well as the underlying DbStatement related to this DbResultSet After this action the DbResultSet is 'empty' or cleaned up in a golang world
func (*DbResultSet) Data ¶
func (rset *DbResultSet) Data() []interface{}
Data return Displayable data in the form of a slice, 'array', of interface{} values
func (*DbResultSet) MetaData ¶
func (rset *DbResultSet) MetaData() *DbResultSetMetaData
MetaData DbResultSet=>DbResultSetMetaData
func (*DbResultSet) Next ¶
func (rset *DbResultSet) Next() (next bool, err error)
Next return true if able to move focus of DbResultSet to the next underlying record or false if the end is reached
type DbResultSetMetaData ¶
type DbResultSetMetaData struct {
// contains filtered or unexported fields
}
DbResultSetMetaData DbResultSet meta data container
func (*DbResultSetMetaData) ColumnTypes ¶
func (rsetmeta *DbResultSetMetaData) ColumnTypes() []*ColumnType
ColumnTypes ColumnType(s) definition(s)
func (*DbResultSetMetaData) Columns ¶
func (rsetmeta *DbResultSetMetaData) Columns() []string
Columns column name(s)
type DbStatement ¶
type DbStatement struct {
// contains filtered or unexported fields
}
DbStatement container representing the underlying DbConnection and allocated sql.Tx transaction
func NewDbStatement ¶
func NewDbStatement(cn *DbConnection) (stmnt *DbStatement, err error)
NewDbStatement invoke a new DbStatement from the DbConnection
func (*DbStatement) Begin ¶
func (stmnt *DbStatement) Begin() (err error)
Begin Invoke a transaction, sql.Tx, from the for ths DbStatement
func (*DbStatement) Close ¶
func (stmnt *DbStatement) Close() (err error)
Close the allocated transaction, sql.Tx associated to this DbStatement It will by default perform a commit before releasing the transaction reference
func (*DbStatement) Execute ¶
func (stmnt *DbStatement) Execute(query string, args ...interface{}) (lastInsertID int64, rowsAffected int64, err error)
Execute execute a none DbResultSet query Usually used for statement like update and insert, or executing db procedures that dont return a record In the case of Insert or Update if the underlying db driver return the lastInsertID and rowsAffected if supported
func (*DbStatement) Query ¶
func (stmnt *DbStatement) Query(query string, args ...interface{}) (rset *DbResultSet, err error)
Query and return a DbResultSet
type ProcessingFunc ¶
type ProcessingFunc = func(dbqry *DBQuery, stage QueryStage, a ...interface{})
ProcessingFunc definition
type QueryStage ¶
type QueryStage int
QueryStage stage
func (QueryStage) String ¶
func (qrystage QueryStage) String() (s string)
type ReadColumnsFunc ¶
type ReadColumnsFunc = func(dbqry *DBQuery, columns []string, columntypes []*ColumnType)
ReadColumnsFunc definition
type ReadRowFunc ¶
ReadRowFunc definition