Documentation
¶
Index ¶
- type Config
- type Database
- func (db *Database) Begin() (*sql.Tx, error)
- func (db *Database) Beginx() (*sqlx.Tx, error)
- func (db *Database) Close() error
- func (db *Database) Exec(query string, args ...interface{}) (sql.Result, error)
- func (db *Database) Get(what interface{}, query string, args ...interface{}) error
- func (db *Database) MustBegin() *sqlx.Tx
- func (db *Database) NamedExec(query string, args interface{}) (sql.Result, error)
- func (db *Database) Ping() error
- func (db *Database) Prepare(query string) (*sql.Stmt, error)
- func (db *Database) Query(query string, args ...interface{}) (IRows, error)
- func (db *Database) QueryRowx(query string, args ...interface{}) IRow
- func (db *Database) Queryx(query string, args ...interface{}) (IRowsx, error)
- func (db *Database) Select(what interface{}, query string, args ...interface{}) error
- func (db *Database) SetMaxIdleConns(limit int)
- func (db *Database) SetMaxOpenConns(limit int)
- type DatabaseMgr
- type IDatabase
- type IDatabaseMgr
- type IRow
- type IRows
- type IRowsx
- type ITx
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Driver string `json:"driver"`
Username string `json:"username"`
Password string `json:"password" config_obscure:"true"`
Hostname string `json:"hostname"`
Port int `json:"port"`
Database string `json:"database"`
BatchSize int `json:"batch_size"`
SetPoolLimits bool `json:"set_pool_limits"`
MaxIdleConns int `json:"max_idle_conns"`
MaxOpenConns int `json:"max_open_conns"`
// contains filtered or unexported fields
}
SQL configuration structure.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
SQL proxy object.
This trainwreck exists so that we can make use of database interfaces.
It might be 100% useless, as `sql.DB` will most likely conform to `IDatabase`, so this file might vanish at some point.
func (*Database) SetMaxIdleConns ¶
func (*Database) SetMaxOpenConns ¶
type DatabaseMgr ¶
type DatabaseMgr struct {
}
Database management.
This is a series of wrappers around Go's internal DB stuff to ensure that we set up max idle/open connections et al.
func (*DatabaseMgr) CheckDB ¶
func (dbm *DatabaseMgr) CheckDB(db IDatabase) error
Check the db connection.
func (*DatabaseMgr) Open ¶
func (dbm *DatabaseMgr) Open(driver string, dsn string) (IDatabase, error)
Open a connection to the database specified in the DSN string.
func (*DatabaseMgr) OpenConfig ¶
func (dbm *DatabaseMgr) OpenConfig(conf *Config) (IDatabase, error)
Open and configure a database connection.
type IDatabase ¶
type IDatabase interface {
MustBegin() *sqlx.Tx
Begin() (*sql.Tx, error)
Beginx() (*sqlx.Tx, error)
Close() error
Exec(string, ...interface{}) (sql.Result, error)
NamedExec(string, interface{}) (sql.Result, error)
Ping() error
Prepare(string) (*sql.Stmt, error)
Query(string, ...interface{}) (IRows, error)
Queryx(string, ...interface{}) (IRowsx, error)
QueryRowx(string, ...interface{}) IRow
Select(interface{}, string, ...interface{}) error
Get(interface{}, string, ...interface{}) error
SetMaxIdleConns(int)
SetMaxOpenConns(int)
}
Interface for `sql.DB` objects.
type IDatabaseMgr ¶
type IRows ¶
type IRows interface {
Close() error
ColumnTypes() ([]*sql.ColumnType, error)
Columns() ([]string, error)
Err() error
Next() bool
NextResultSet() bool
Scan(...interface{}) error
}
Interface for `sql.Rows` objects.
Click to show internal directories.
Click to hide internal directories.