database

package
v0.0.0-...-3f97f43 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveDBMS

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

func (*ActiveDBMS) Connections

func (atvdbms *ActiveDBMS) Connections() (cns []string)

func (*ActiveDBMS) Dispose

func (atvdbms *ActiveDBMS) Dispose()

func (*ActiveDBMS) DriverName

func (atvdbms *ActiveDBMS) DriverName(alias string) (driver string)

func (*ActiveDBMS) Execute

func (atvdbms *ActiveDBMS) Execute(a interface{}, excargs ...interface{}) (exctr *Executor)

func (*ActiveDBMS) Exists

func (atvdbms *ActiveDBMS) Exists(alias string) (exists bool)

func (*ActiveDBMS) InOut

func (atvdbms *ActiveDBMS) InOut(in interface{}, out io.Writer, ioargs ...interface{}) (err error)

func (*ActiveDBMS) Info

func (atvdbms *ActiveDBMS) Info(alias ...string) (info map[string]interface{})

func (*ActiveDBMS) Query

func (atvdbms *ActiveDBMS) Query(a interface{}, qryargs ...interface{}) (reader *Reader)

func (*ActiveDBMS) Register

func (atvdbms *ActiveDBMS) Register(alias string, driver string, datasource string, a ...interface{}) (registered bool)

func (*ActiveDBMS) Unregister

func (atvdbms *ActiveDBMS) Unregister(alias string) (unregistered bool)

type CSVReader

type CSVReader struct {
	Headers    bool
	ColDelim   string
	RowDelim   string
	IncludeEOF bool
	AltHeaders []string
	// contains filtered or unexported fields
}

CSVReader -

func NewCSVReader

func NewCSVReader(rdr *Reader, err error, a ...interface{}) (csvr *CSVReader)

NewCSVReader - over rdr*Reader

func (*CSVReader) Read

func (csvr *CSVReader) Read(p []byte) (n int, err error)

Read - refer to io.Reader

func (*CSVReader) ReadRune

func (csvr *CSVReader) ReadRune() (r rune, size int, err error)

ReadRune - refer to io.RuneReader

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 driver of Connection

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 ColumnTypeHandle

type ColumnTypeHandle interface {
	Name() string
	Numeric() bool
	HasNullable() bool
	HasLength() bool
	HasPrecisionScale() bool
	Nullable() bool
	Length() int64
	DatabaseType() string
	Precision() int64
	Scale() int64
	Type() reflect.Type
}

ColumnTypeHandle interface defining column type api

type Connection

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

Connection - struct

func NewConnection

func NewConnection(dbms *DBMS, driverName, dataSourceName string) (cn *Connection)

NewConnection - dbms,driver name and datasource name (cn-string)

func (*Connection) DataSource

func (cn *Connection) DataSource() (datasource string)

func (*Connection) Dispose

func (cn *Connection) Dispose() (err error)

func (*Connection) Driver

func (cn *Connection) Driver() (driver string)

func (*Connection) GblExecute

func (cn *Connection) GblExecute(query interface{}, prms ...interface{}) (exctr *Executor, err error)

GblExecute - public for query()*Executor

func (*Connection) GblQuery

func (cn *Connection) GblQuery(query interface{}, prms ...interface{}) (reader *Reader, err error)

GblQuery - public for query() *Reader

func (*Connection) InOut

func (cn *Connection) InOut(in interface{}, out io.Writer, ioargs ...interface{}) (err error)

InOut - OO{ in interface{} -> out io.Writer } loop till no input

func (*Connection) Info

func (cn *Connection) Info() (info map[string]interface{})

func (*Connection) IsConnected

func (cn *Connection) IsConnected() (connected bool)

func (*Connection) IsRemote

func (cn *Connection) IsRemote() bool

func (*Connection) Ping

func (cn *Connection) Ping() (status map[string]interface{})

func (*Connection) SetMaxIdleConns

func (cn *Connection) SetMaxIdleConns(idlcons int)

func (*Connection) SetMaxOpenConns

func (cn *Connection) SetMaxOpenConns(opencons int)

type DBMS

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

DBMS - struct

func GLOBALDBMS

func GLOBALDBMS() *DBMS

GLOBALDBMS - Global DBMS instance

func NewDBMS

func NewDBMS() (dbms *DBMS)

NewDBMS - instance

func (*DBMS) ActiveDBMS

func (dbms *DBMS) ActiveDBMS(rntme active.Runtime, prmsfnc func() parameters.ParametersAPI) (atvdbms *ActiveDBMS)

ActiveDBMS return registered connections

func (*DBMS) Connection

func (dbms *DBMS) Connection(alias string) (cn *Connection)

Connection return registered connections

func (*DBMS) Connections

func (dbms *DBMS) Connections() (cns []string)

Connections return list of registered connection aliases

func (*DBMS) DriverName

func (dbms *DBMS) DriverName(alias string) (driver string)

func (*DBMS) Execute

func (dbms *DBMS) Execute(a interface{}, excargs ...interface{}) (exctr *Executor)

ExecuteSettings - map[string]interface{} settings wrapper for Execute settings : alias - cn alias query - statement args - [] slice of arguments success - func(r) event when ready error - func(error) event when encountering an error finalize - func() final wrapup event repeatable - true keep underlying stmnt open and allows for repeating query script - script handle

func (*DBMS) Exists

func (dbms *DBMS) Exists(alias string) (exists bool, dbcn *Connection)

Exists - alias exist <= exist[true], dbcn[*Connection]

func (*DBMS) InOut

func (dbms *DBMS) InOut(in interface{}, out io.Writer, ioargs ...interface{}) (err error)

InOut - OO{ in io.Reader -> out io.Writer } loop till no input

func (*DBMS) InOutS

func (dbms *DBMS) InOutS(in interface{}, ioargs ...interface{}) (out string, err error)

InOutS - OO{ in io.Reader -> out string } loop till no input

func (*DBMS) Info

func (dbms *DBMS) Info(alias ...string) (info map[string]interface{})

Info return status info of all aliases or alias... provided

func (*DBMS) Query

func (dbms *DBMS) Query(a interface{}, qryargs ...interface{}) (reader *Reader)

Query - map[string]interface{} settings wrapper for Query settings : alias - cn alias query - statement args - [] slice of arguments success - func(r) event when ready error - func(error) event when encountering an error finalize - func() final wrapup event repeatable - true keep underlying stmnt open and allows for repeating query script - script handle

func (*DBMS) QueryJSON

func (dbms *DBMS) QueryJSON(query interface{}, prms ...interface{}) (reader *Reader)

func (*DBMS) Register

func (dbms *DBMS) Register(alias string, driver string, datasource string, a ...interface{}) (registered bool)

Register - new connection alias, driverName, dataSourceName

func (*DBMS) RegisterDriver

func (dbms *DBMS) RegisterDriver(driver string, invokedbcall func(string, ...interface{}) (*sql.DB, error))

RegisterDriver - register driver name for invokable db call

func (*DBMS) Unregister

func (dbms *DBMS) Unregister(alias string) (unregistered bool)

Unegister connection aliase

type DBMSAPI

type DBMSAPI interface {
	Connections() (cns []string)
	Unregister(alias string) (unregistered bool)
	Register(alias string, driver string, datasource string, a ...interface{}) (registered bool)
	Exists(alias string) (exists bool)
	Info(alias ...string) map[string]interface{}
	Query(a interface{}, qryargs ...interface{}) (reader *Reader)
	Execute(a interface{}, excargs ...interface{}) (exctr *Executor)
	InOut(in interface{}, out io.Writer, ioargs ...interface{}) (err error)
	DriverName(alias string) string
}

type ExecError

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

ExecError - struct

func (*ExecError) Error

func (execerr *ExecError) Error() string

func (*ExecError) Statement

func (execerr *ExecError) Statement() string

Statement return statement executed that caused error

type Executor

type Executor struct {
	Stmnt string

	OnSuccess  interface{}
	OnError    interface{}
	OnFinalize interface{}
	OnClose    func(*Executor)
	// contains filtered or unexported fields
}

Executor - struct

func (*Executor) Close

func (exctr *Executor) Close() (err error)

Close - Executor

func (*Executor) Err

func (exctr *Executor) Err() (err error)

Err - return last Error

func (*Executor) JSON

func (exctr *Executor) JSON() (s string, err error)

JSON execute *Executor and return json as string

func (*Executor) JSONReader

func (exctr *Executor) JSONReader() (jsnrdr *JSONReader)

JSONReader return *JSONReader

func (*Executor) Repeat

func (exctr *Executor) Repeat(args ...interface{}) (err error)

Repeat - repeat last query by repopulating parameters but dont regenerate last statement

func (*Executor) ToJSON

func (exctr *Executor) ToJSON(w io.Writer) (err error)

ToJSON write *Executor out to json

type Field

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

Field - struct

func (*Field) Name

func (fld *Field) Name() (nme string)

Name - of Field

func (*Field) Type

func (fld *Field) Type() (tpe *ColumnType)

Type - ColumnType of Field

func (*Field) Value

func (fld *Field) Value() (val interface{})

Value - of Field

type JSONDataEntry

type JSONDataEntry interface {
	JSON() string
}

type JSONEntry

type JSONEntry interface {
	JSON() string
}

type JSONReader

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

JSONReader - struct

func NewJSONReader

func NewJSONReader(rdr *Reader, exctr *Executor, err error) (jsnr *JSONReader)

NewJSONReader - over rdr*Reader or exctr*Executor

func (*JSONReader) Read

func (jsnr *JSONReader) Read(p []byte) (n int, err error)

Read - refer to io.Reader

func (*JSONReader) ReadRune

func (jsnr *JSONReader) ReadRune() (r rune, size int, err error)

ReadRune - refer to io.RuneReader

type RWSAPI

type RWSAPI interface {
	Err() error
	Close() error
	Next() bool
	Scan(dest ...interface{}) error
	ColumnTypes() ([]*ColumnType, error)
	Columns() ([]string, error)
}

RWSAPI - interface

type RWSReader

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

func (*RWSReader) Close

func (rwsrdr *RWSReader) Close() (err error)

func (*RWSReader) ColumnTypes

func (rwsrdr *RWSReader) ColumnTypes() (coltypes []*ColumnType, err error)

func (*RWSReader) Columns

func (rwsrdr *RWSReader) Columns() (cls []string, err error)

func (*RWSReader) Err

func (rwsrdr *RWSReader) Err() (err error)

func (*RWSReader) Next

func (rwsrdr *RWSReader) Next() (nxt bool)

func (*RWSReader) Scan

func (rwsrdr *RWSReader) Scan(dest ...interface{}) (err error)

type Reader

type Reader struct {
	*Executor

	OnColumns   interface{}
	OnRow       interface{}
	OnValidData interface{}
	OnClose     func(*Reader)
	// contains filtered or unexported fields
}

Reader - struct

func (*Reader) CSV

func (rdr *Reader) CSV() (s string, err error)

CSV readall *Reader and return csv as string

func (*Reader) CSVReader

func (rdr *Reader) CSVReader(a ...interface{}) (csvrdr *CSVReader)

CSVReader return *CSVReader

func (*Reader) Close

func (rdr *Reader) Close() (err error)

Close the Reader as well as the underlying Executor related to this Reader After this action the Reader is 'empty' or cleaned up in a golang world

func (*Reader) ColumnTypes

func (rdr *Reader) ColumnTypes() []*ColumnType

ColumnTypes return Column types in form of a slice, 'array', of []*ColumnType values

func (*Reader) Columns

func (rdr *Reader) Columns() []string

Columns return Column names in form of a slice, 'array', of string values

func (*Reader) DATAJSONFPrint

func (rdr *Reader) DATAJSONFPrint(w io.Writer) (err error)

func (*Reader) DATAJSONFPrintln

func (rdr *Reader) DATAJSONFPrintln(w io.Writer) (err error)

func (*Reader) Data

func (rdr *Reader) Data(cols ...string) (dspdata []interface{})

Data return Displayable data in the form of a slice, 'array', of interface{} values

func (*Reader) DataMap

func (rdr *Reader) DataMap() (datamap map[string]interface{})

DataMap return Displayable data in the form of a map[string]interface{} column and values

func (*Reader) Field

func (rdr *Reader) Field(name string) (val interface{})

func (*Reader) IsFirst

func (rdr *Reader) IsFirst() bool

IsFirst - indicate if Reader focus is on first record

func (*Reader) IsFocused

func (rdr *Reader) IsFocused() bool

IsFocused - indicate if Reader focus is on a record

func (*Reader) IsLast

func (rdr *Reader) IsLast() bool

IsLast - indicate if Reader focus is on last record

func (*Reader) IsMore

func (rdr *Reader) IsMore() bool

IsMore - indicate if Reader is able to more records

func (*Reader) JSON

func (rdr *Reader) JSON() (s string, err error)

JSON readall *Reader and return json as string

func (*Reader) JSONData

func (rdr *Reader) JSONData(cols ...string) (s string, err error)

JSONData readall *Reader of current record data and return json as string

func (*Reader) JSONReader

func (rdr *Reader) JSONReader() (jsnrdr *JSONReader)

JSONReader return *JSONReader

func (*Reader) Next

func (rdr *Reader) Next() (next bool, err error)

Next return true if able to move focus of Reader to the next underlying record or false if the end is reached

func (*Reader) Repeat

func (rdr *Reader) Repeat(a ...interface{}) (err error)

Repeat - repeat last query by repopulating parameters but dont regenerate last statement

func (*Reader) ToCSV

func (rdr *Reader) ToCSV(w io.Writer, a ...interface{}) (err error)

ToCSV write *Reader out to json

func (*Reader) ToJSON

func (rdr *Reader) ToJSON(w io.Writer) (err error)

ToJSON write *Reader out to json

func (*Reader) ToJSONData

func (rdr *Reader) ToJSONData(w io.Writer, cols ...string) (err error)

ToJSONData write *Reader out to json of current record data

type ReaderHandle

type ReaderHandle interface {
	ColumnTypes() []ColumnTypeHandle
	Columns() []string
	Field(string) interface{}
	Data(...string) []interface{}
	Next() (bool, error)
	ToJSON(w io.Writer) error
	ToJSONData(w io.Writer) error
	JSON() (string, error)
	JSONData(...string) (string, error)
	Close() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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