Documentation ¶
Index ¶
Constants ¶
View Source
const ( KeyTransaction string = "_DB_TXN" StringDeadlock string = "Error 1213" // Deadlock detected. StringConnClosed string = "Error 2006" // MySQL server connection closed. StringLostConn string = "Error 2013" // Lost connection during query. )
Variables ¶
View Source
var ( ErrNoDriver error = errors.Base("no driver provided") ErrNoUsername error = errors.Base("no username provided") ErrNoPassword error = errors.Base("no password provided") ErrNoHostname error = errors.Base("no hostname provided") ErrNoDatabase error = errors.Base("no database name provided") )
View Source
var ( ErrTxnKeyNotFound error = errors.Base("transaction key not found") ErrTxnKeyNotTxn error = errors.Base("key value is not a transaction") ErrTxnContext error = errors.Base("could not create transaction context") ErrTxnStart error = errors.Base("could not start transaction") ErrTxnDeadlock error = errors.Base("deadlock found when trying to get lock") ErrServerConnClosed error = errors.Base("server connection closed") ErrLostConn error = errors.Base("lost connection during query") )
View Source
var ( // The empty cursor. EmptyCursor = &Cursor{Offset: 0, Limit: 0} )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Driver string `json:"driver"` Username string `json:"username"` Password string `config_obscure:"true" json:"password"` 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 Cursor ¶ added in v0.3.3
TODO: Look, this sucks... offset/limit cursors are just fail. TODO: Rework this to be a proper cursor!
type Database ¶
type Database interface { // Pings the database connection to ensure it is alive and connected. Ping() error // Close a database connection. This does nothing if the connection // is already closed. Close() error // Set the maximum idle connections. SetMaxIdleConns(int) // Set the maximum open connections. SetMaxOpenConns(int) // Return the transaction (if any) from the given context. Tx(context.Context) (*sqlx.Tx, error) // Initiate a transaction. Returns a new context that contains the // database transaction session as a value. Begin(context.Context) (context.Context, error) // Initiate a transaction commit. Commit(context.Context) error // Initiate a transaction rollback. Rollback(context.Context) error // Parses the given error looking for common MySQL error conditions. // // If one is found, then a Golang error describing the condition is // raised. // // If nothing interesting is found, then the original error is // returned. GetError(error) error }
type Manager ¶ added in v0.5.0
type Manager interface { Open(string, string) (Database, error) OpenConfig(*Config) (Database, error) CheckDB(Database) error }
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.
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)
Click to show internal directories.
Click to hide internal directories.