Documentation ¶
Index ¶
- type Config
- type Cursor
- 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 NullBool
- type NullByte
- type NullFloat64
- type NullInt16
- type NullInt32
- type NullInt64
- type NullString
- type NullTime
- 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"` UsernameSecret string `json:"username_secret"` Password string `json:"password" config_obscure:"true"` PasswordSecret string `json:"password_secret"` 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.
type IRowsx ¶
type IRowsx interface { Close() error ColumnTypes() ([]*sql.ColumnType, error) Columns() ([]string, error) Err() error Next() bool NextResultSet() bool Scan(...interface{}) error StructScan(interface{}) error }
Interface for `sqlx.Rows` objects.
type NullBool ¶ added in v0.3.3
func (NullBool) MarshalJSON ¶ added in v0.3.3
type NullByte ¶ added in v0.3.3
func (NullByte) MarshalJSON ¶ added in v0.3.3
type NullFloat64 ¶ added in v0.3.3
type NullFloat64 struct {
sql.NullFloat64
}
func (NullFloat64) MarshalJSON ¶ added in v0.3.3
func (x NullFloat64) MarshalJSON() ([]byte, error)
type NullInt16 ¶ added in v0.3.3
func (NullInt16) MarshalJSON ¶ added in v0.3.3
type NullInt32 ¶ added in v0.3.3
func (NullInt32) MarshalJSON ¶ added in v0.3.3
type NullInt64 ¶ added in v0.3.3
func (NullInt64) MarshalJSON ¶ added in v0.3.3
type NullString ¶ added in v0.3.3
type NullString struct {
sql.NullString
}
func (NullString) MarshalJSON ¶ added in v0.3.3
func (x NullString) MarshalJSON() ([]byte, error)
type NullTime ¶ added in v0.3.3
func (NullTime) MarshalJSON ¶ added in v0.3.3
Click to show internal directories.
Click to hide internal directories.