Documentation ¶
Index ¶
- func IsTableExists(q Queryer, table, schema string) bool
- func PreparePositionalArgsQuery(query string) string
- type Connection
- type ConnectionConfig
- type DBO
- func (dbo *DBO) Begin() (*SqlTx, error)
- func (dbo *DBO) ConnType() string
- func (dbo *DBO) Exec(query string, args ...interface{}) (sql.Result, error)
- func (dbo DBO) Init() (*DBO, error)
- func (dbo *DBO) Prepare(query string) (*SqlStmt, error)
- func (dbo *DBO) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (dbo *DBO) QueryRow(query string, args ...interface{}) *sql.Row
- type IConnType
- type IOptions
- type Options
- type PostgresConnectionConfig
- type Queryer
- type SqlStmt
- type SqlTx
- func (tx *SqlTx) Commit() error
- func (tx *SqlTx) ConnType() string
- func (tx *SqlTx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (tx *SqlTx) Prepare(query string) (*SqlStmt, error)
- func (tx *SqlTx) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (tx *SqlTx) QueryRow(query string, args ...interface{}) *sql.Row
- func (tx *SqlTx) Rollback() error
- func (tx *SqlTx) Stmt(stmt *SqlStmt) *SqlStmt
- type Transaction
- type TransactionId
- type TransactionPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTableExists ¶ added in v2.4.0
IsTableExists check if table exists
func PreparePositionalArgsQuery ¶ added in v2.4.0
PreparePositionalArgsQuery Position argument
Types ¶
type Connection ¶
type Connection interface { // String Get prepared URI String() string // GetDbType return database type GetDbType() string // GetMaxConnection return maximum connection GetMaxConnection() int // GetConnMaxLifetime return maximum lifetime GetConnMaxLifetime() int // GetMaxIdleConns return maximum idle connections count GetMaxIdleConns() int }
Connection Database Object Connection Interface
type ConnectionConfig ¶
type ConnectionConfig struct { // Database host Host string `yaml:"host"` // Database port Port int `yaml:"port"` // Database name Name string `yaml:"name"` // Database user User string `yaml:"user"` // Database password Password string `yaml:"password"` // Maximum connections MaxConnections int `yaml:"maxConnections"` // Maximum idle connections count MaxIdleConnections int `yaml:"maxIdleConnections"` // Connection idle lifetime ConnectionIdleLifetime int `yaml:"connectionIdleLifetime"` }
ConnectionConfig Client connection config
func (*ConnectionConfig) GetConnMaxLifetime ¶
func (cc *ConnectionConfig) GetConnMaxLifetime() int
GetConnMaxLifetime Connection idle lifetime
func (*ConnectionConfig) GetMaxConnection ¶
func (cc *ConnectionConfig) GetMaxConnection() int
GetMaxConnection Get Max Connection
func (*ConnectionConfig) GetMaxIdleConns ¶
func (cc *ConnectionConfig) GetMaxIdleConns() int
GetMaxIdleConns Connection max idle connections
type DBO ¶
type DBO struct { *sql.DB Options Connection Connection }
DBO Main Database Object
type IConnType ¶ added in v2.4.0
type IConnType interface { // ConnType return connection type ConnType() string }
IConnType interface helps to get connection type
type Options ¶
type Options struct { // Debug mode shows logs Debug bool // Logger Logger gocli.Logger // Query preprocessing QueryProcessor func(query string) string // TTL for transaction TransactionTTL time.Duration `yaml:"transactionTTL"` // contains filtered or unexported fields }
Options database object options
type PostgresConnectionConfig ¶
type PostgresConnectionConfig struct { ConnectionConfig `yaml:",inline"` // SSL mode SSLMode string `yaml:"sslMode"` // Use with pgpool BinaryParameters bool `yaml:"binaryParameters"` }
PostgresConnectionConfig Postgres connection config
func (*PostgresConnectionConfig) GetDbType ¶
func (pcc *PostgresConnectionConfig) GetDbType() string
GetDbType Get database type
func (*PostgresConnectionConfig) String ¶
func (pcc *PostgresConnectionConfig) String() string
To string
type Queryer ¶
type Queryer interface { // Exec query Exec(query string, args ...interface{}) (sql.Result, error) // Prepare statement Prepare(query string) (*SqlStmt, error) // Query rows Query(query string, args ...interface{}) (*sql.Rows, error) // QueryRow single row QueryRow(query string, args ...interface{}) *sql.Row }
Queryer interface
type SqlStmt ¶
SqlStmt Statement object
type SqlTx ¶
type SqlTx struct { *sql.Tx Options Connection Connection // contains filtered or unexported fields }
SqlTx Transaction object
type Transaction ¶
type Transaction struct { // Time to live in unix timestampt // 0 - no TTL for transaction TTL int // contains filtered or unexported fields }
Transaction params
type TransactionId ¶
type TransactionId string
TransactionId transaction identifier
func GenTransactionId ¶
func GenTransactionId() TransactionId
GenTransactionId Generate transaction id
type TransactionPool ¶
type TransactionPool struct {
// contains filtered or unexported fields
}
TransactionPool transaction pool
func NewTransactionPool ¶
func NewTransactionPool() *TransactionPool
NewTransactionPool Create transaction pool
func (*TransactionPool) Get ¶
func (p *TransactionPool) Get(id TransactionId) *SqlTx
Get transaction if exists
func (*TransactionPool) Set ¶
func (p *TransactionPool) Set(id TransactionId, tx *SqlTx) *TransactionPool
Set transaction
func (*TransactionPool) UnSet ¶
func (p *TransactionPool) UnSet(id TransactionId) *TransactionPool
UnSet transaction