Documentation ¶
Index ¶
- Variables
- type Connection
- type ConnectionParameters
- func (c *ConnectionParameters) GetConnectTimeout() time.Duration
- func (c *ConnectionParameters) GetConnectionMaxIdleTime() time.Duration
- func (c *ConnectionParameters) GetConnectionMaxLifetime() time.Duration
- func (c *ConnectionParameters) GetDSN() string
- func (c *ConnectionParameters) GetDSNWithHiddenCredentials() string
- func (c *ConnectionParameters) GetDriverName() string
- func (c *ConnectionParameters) GetExecTimeout() time.Duration
- func (c *ConnectionParameters) GetMaxIdleConnections() int
- func (c *ConnectionParameters) GetMaxOpenConnections() int
- func (c *ConnectionParameters) GetQueryTimeout() time.Duration
- func (c *ConnectionParameters) HasConnectTimeout() bool
- func (c *ConnectionParameters) HasConnectionMaxIdleTime() bool
- func (c *ConnectionParameters) HasConnectionMaxLifetime() bool
- func (c *ConnectionParameters) HasExecTimeout() bool
- func (c *ConnectionParameters) HasMaxIdleConnections() bool
- func (c *ConnectionParameters) HasMaxOpenConnections() bool
- func (c *ConnectionParameters) HasQueryTimeout() bool
- func (c *ConnectionParameters) SetConnectTimeout(t time.Duration)
- func (c *ConnectionParameters) SetConnectionMaxIdleTime(m time.Duration)
- func (c *ConnectionParameters) SetConnectionMaxLifetime(m time.Duration)
- func (c *ConnectionParameters) SetDriverName(name string)
- func (c *ConnectionParameters) SetExecTimeout(t time.Duration)
- func (c *ConnectionParameters) SetMaxIdleConnections(m int)
- func (c *ConnectionParameters) SetMaxOpenConnections(m int)
- func (c *ConnectionParameters) SetQueryTimeout(t time.Duration)
- type Data
- type DataChunkTransport
- type Result
Constants ¶
This section is empty.
Variables ¶
var ( DefaultConnectTimeout = 10 * time.Second DefaultQueryTimeout = 10 * time.Second DefaultExecTimeout = 10 * time.Second DefaultMaxOpenConnections = 100 DefaultMaxIdleConnections = 1 DefaultConnectionMaxLifetime = 10 * time.Minute DefaultConnectionMaxIdleTime = 1 * time.Second )
var ( // ErrNilData specifies the situation with result data is nil ErrNilData = fmt.Errorf("ErrNilData") // ErrNilRows specifies the situation with result rows is nil ErrNilRows = fmt.Errorf("ErrNilRows") // ErrEmptyRows specifies the situation with result no rows available to scan from ErrEmptyRows = fmt.Errorf("ErrEmptyRows") )
var ( // ErrNilResult specifies the situation with result is nil ErrNilResult = fmt.Errorf("ErrNilResult") )
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a connection to a database
func NewConnection ¶
func NewConnection(params *ConnectionParameters) *Connection
NewConnection creates new database connection
func NewConnectionConfig ¶
func NewConnectionConfig(driverName string, cfg interface{}) *Connection
NewConnectionConfig creates new database connection from config
func (*Connection) Exec ¶
func (c *Connection) Exec(sql string, args ...interface{}) error
Exec runs given sql query w/o response
func (*Connection) GetParams ¶
func (c *Connection) GetParams() *ConnectionParameters
func (*Connection) Query ¶
func (c *Connection) Query(sql string, args ...interface{}) *Result
Query runs given sql query with response as one struct which includes error (if any)
type ConnectionParameters ¶
type ConnectionParameters struct { // driverName which to connect with DriverName string // username which to connect with Username string // password which to connect with Password string // hostname where to connect to Hostname string // port where to connect to Port int // database to work with Database string // Ready-to-use DSN string Dsn string // DSN string with hidden credentials. Can be used in logs, etc DsnHiddenCredentials string // ConnectTimeout specifies connect timeout [OPTIONAL] ConnectTimeout *time.Duration // QueryTimeout specifies query timeout [OPTIONAL] QueryTimeout *time.Duration // ExecTimeout specifies exec timeout [OPTIONAL] ExecTimeout *time.Duration // MaxOpenConnections specifies max number of open connections [OPTIONAL] MaxOpenConnections *int // MaxIdleConnections specifies max number of idling connections [OPTIONAL] MaxIdleConnections *int // ConnectionMaxLifeTime specifies max connection lifetime [OPTIONAL] ConnectionMaxLifetime *time.Duration // ConnectionMaxIdleTime specifies max connection idling time [OPTIONAL] ConnectionMaxIdleTime *time.Duration }
ConnectionParameters specifies database connection parameters
func NewConnectionParameters ¶
func NewConnectionParameters(driverName, username, password string, hostname string, port int, database, dsn string) *ConnectionParameters
NewConnectionParameters creates new database conenction parameters
func NewConnectionParametersConfig ¶
func NewConnectionParametersConfig(driverName string, untyped interface{}) *ConnectionParameters
NewConnectionParametersConfig creates new database connection parameters from config
func (*ConnectionParameters) GetConnectTimeout ¶
func (c *ConnectionParameters) GetConnectTimeout() time.Duration
func (*ConnectionParameters) GetConnectionMaxIdleTime ¶
func (c *ConnectionParameters) GetConnectionMaxIdleTime() time.Duration
func (*ConnectionParameters) GetConnectionMaxLifetime ¶
func (c *ConnectionParameters) GetConnectionMaxLifetime() time.Duration
func (*ConnectionParameters) GetDSN ¶
func (c *ConnectionParameters) GetDSN() string
GetDSN gets DSN
func (*ConnectionParameters) GetDSNWithHiddenCredentials ¶
func (c *ConnectionParameters) GetDSNWithHiddenCredentials() string
GetDSNWithHiddenCredentials gets DSN with hidden credentials. Handy for logging
func (*ConnectionParameters) GetDriverName ¶
func (c *ConnectionParameters) GetDriverName() string
GetDriverName gets name of the driver
func (*ConnectionParameters) GetExecTimeout ¶
func (c *ConnectionParameters) GetExecTimeout() time.Duration
func (*ConnectionParameters) GetMaxIdleConnections ¶
func (c *ConnectionParameters) GetMaxIdleConnections() int
func (*ConnectionParameters) GetMaxOpenConnections ¶
func (c *ConnectionParameters) GetMaxOpenConnections() int
func (*ConnectionParameters) GetQueryTimeout ¶
func (c *ConnectionParameters) GetQueryTimeout() time.Duration
func (*ConnectionParameters) HasConnectTimeout ¶
func (c *ConnectionParameters) HasConnectTimeout() bool
func (*ConnectionParameters) HasConnectionMaxIdleTime ¶
func (c *ConnectionParameters) HasConnectionMaxIdleTime() bool
func (*ConnectionParameters) HasConnectionMaxLifetime ¶
func (c *ConnectionParameters) HasConnectionMaxLifetime() bool
func (*ConnectionParameters) HasExecTimeout ¶
func (c *ConnectionParameters) HasExecTimeout() bool
func (*ConnectionParameters) HasMaxIdleConnections ¶
func (c *ConnectionParameters) HasMaxIdleConnections() bool
func (*ConnectionParameters) HasMaxOpenConnections ¶
func (c *ConnectionParameters) HasMaxOpenConnections() bool
func (*ConnectionParameters) HasQueryTimeout ¶
func (c *ConnectionParameters) HasQueryTimeout() bool
func (*ConnectionParameters) SetConnectTimeout ¶
func (c *ConnectionParameters) SetConnectTimeout(t time.Duration)
func (*ConnectionParameters) SetConnectionMaxIdleTime ¶
func (c *ConnectionParameters) SetConnectionMaxIdleTime(m time.Duration)
func (*ConnectionParameters) SetConnectionMaxLifetime ¶
func (c *ConnectionParameters) SetConnectionMaxLifetime(m time.Duration)
func (*ConnectionParameters) SetDriverName ¶
func (c *ConnectionParameters) SetDriverName(name string)
SetDriverName sets name of the driver
func (*ConnectionParameters) SetExecTimeout ¶
func (c *ConnectionParameters) SetExecTimeout(t time.Duration)
func (*ConnectionParameters) SetMaxIdleConnections ¶
func (c *ConnectionParameters) SetMaxIdleConnections(m int)
func (*ConnectionParameters) SetMaxOpenConnections ¶
func (c *ConnectionParameters) SetMaxOpenConnections(m int)
func (*ConnectionParameters) SetQueryTimeout ¶
func (c *ConnectionParameters) SetQueryTimeout(t time.Duration)
type Data ¶
type Data struct { // Rows specifies rows returned from the database Rows *databasesql.Rows // contains filtered or unexported fields }
Data describes data returned from the database
func (*Data) AllFn ¶
func (d *Data) AllFn(extractor func(*databasesql.Rows) (interface{}, error)) (result []interface{}, err error)
func (*Data) GetRows ¶
func (d *Data) GetRows() *databasesql.Rows
GetRows return rows returned from the database
type DataChunkTransport ¶
type DataChunkTransport struct { }
type Result ¶
type Result struct { // Data returned by the database *Data // Error returned by the database Error error }
Result specifies result returned by the database - whihc encludes returned data and error code in case of an error
func (*Result) GetRows ¶
func (r *Result) GetRows() *databasesql.Rows
GetRows return rows returned from the database