db

package
v0.0.0-...-a2e018f Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DbFormatColDelimSettings

func DbFormatColDelimSettings(coldelim ...string) (readsettings map[string]string)

DbFormatColDelimSettings DbFormatColDelimSettings

func RegisterDbReadFormat

func RegisterDbReadFormat(formatname string, settings map[string]string, formatFunction func(map[string]string, *DbResultSet, io.Writer) error)

RegisterDbReadFormat RegisterDbReadFormat

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) Name

func (colType *ColumnType) Name() string

Name ColumnType.Name()

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

type DBExecuted struct {
	LastInsertId int64
	RowsAffected int64
	Err          error
}

DBExecuted controller

type DBQuery

type DBQuery struct {
	RSet *DbResultSet

	Err error
	// contains filtered or unexported fields
}

DBQuery DBQuery controller

func (*DBQuery) Columns

func (dbqry *DBQuery) Columns() []string

func (*DBQuery) Data

func (dbqry *DBQuery) Data() []interface{}

Data returns an array if data of the current row from the underlying resultset

func (*DBQuery) Map

func (dbqry *DBQuery) Map(expsettings ...map[string]interface{}) (dbrecmp map[string]interface{})

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) Next

func (dbqry *DBQuery) Next() bool

Next execute the Next record method of the underlying resultset

func (*DBQuery) PrintResult

func (dbqry *DBQuery) PrintResult(out iorw.Printing, 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

func (*DBQuery) Process

func (dbqry *DBQuery) Process() (err error)

Process reading Columns then reading rows one by one till eof and finally indicate done processing

func (*DBQuery) ReadAll

func (dbqry *DBQuery) ReadAll(w io.Writer, format string)

ReadAll ReadAll

func (*DBQuery) ReadAllCustom

func (dbqry *DBQuery) ReadAllCustom(w io.Writer, settings map[string]string, formatFunction func(map[string]string, *DbResultSet, io.Writer) error)

ReadAllCustom ReadAllCustom

type DbConnection

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

func NewDbConnection

func NewDbConnection(cnsettings ...string) (dbcn *DbConnection)

func (*DbConnection) AltUser

func (dbcn *DbConnection) AltUser() string

func (*DbConnection) DbName

func (dbcn *DbConnection) DbName() string

func (*DbConnection) Driver

func (dbcn *DbConnection) Driver() string

func (*DbConnection) Execute

func (dbcn *DbConnection) Execute(query string, args ...interface{}) (lastInsertID int64, rowsAffected int64, err error)

Execute - Execute (query) refer to golang sql connection Execute method

func (*DbConnection) LoadCnSettings

func (dbcn *DbConnection) LoadCnSettings(cnsettings ...string)

func (*DbConnection) LockDBCN

func (dbcn *DbConnection) LockDBCN()

func (*DbConnection) ParseQuery

func (dbcn *DbConnection) ParseQuery(query string, ignoreCase bool, validNames ...string) (parsedquery []string)

query e.g 'SELECT :TEST-PARAM AS param' where :TEST-PARAM is name of parameter

func (*DbConnection) Path

func (dbcn *DbConnection) Path() string

func (*DbConnection) Query

func (dbcn *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

func (*DbConnection) Schema

func (dbcn *DbConnection) Schema() string

func (*DbConnection) UnlockDBCN

func (dbcn *DbConnection) UnlockDBCN()

func (*DbConnection) User

func (dbcn *DbConnection) User() string

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 DbmsManager

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

func DBMSManager

func DBMSManager() *DbmsManager

func (*DbmsManager) Dbms

func (dbmsmngr *DbmsManager) Dbms(alias string) (dbcn *DbConnection)

func (*DbmsManager) Execute

func (dbmngr *DbmsManager) 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 (*DbmsManager) Query

func (dbmngr *DbmsManager) Query(alias string, query string, args ...interface{}) (dbquery *DBQuery)

Query query aliased connection and returns a DBQuery controller for the underlying resultset

func (*DbmsManager) RegisterDbms

func (dbmsmngr *DbmsManager) RegisterDbms(alias string, cnsettings ...string)

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

type ReadRowFunc = func(dbqry *DBQuery, data []interface{}, firstRec bool, lastRec bool)

ReadRowFunc definition

Jump to

Keyboard shortcuts

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