Documentation ¶
Index ¶
- func ConfigConnection(db *sql.DB, connMaxLifetime time.Duration, maxOpenConnections int, ...)
- type Database
- func (d Database) Connection() inter.Connection
- func (d Database) Exec(sql string, args ...interface{}) sql.Result
- func (d Database) ExecE(sql string, args ...interface{}) (sql.Result, error)
- func (d Database) Query(sql string, args ...interface{}) support.Collection
- func (d Database) QueryE(sql string, args ...interface{}) (support.Collection, error)
- type MySQL
- type PostgreSQL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func NewDatabase ¶
func NewDatabase(app inter.App, connection inter.Connection) *Database
func (Database) Connection ¶
func (d Database) Connection() inter.Connection
func (Database) Exec ¶
Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.
func (Database) ExecE ¶
ExecE executes a query without returning any rows. The args are for any placeholder parameters in the query.
type MySQL ¶
type MySQL struct { Host string Port int Database string Username string Password string Parameters map[string]string // When the open connection limit is reached, and all connections are in-use, // any new database tasks that your application needs to execute will be forced // to wait until a connection becomes free and marked as idle. To mitigate this // you can set a fixed, fast, timeout when making database calls. // Default 10 seconds QueryTimeout time.Duration // Set the maximum lifetime of a connection to 1 hour. Setting it to 0 means // that there is no maximum lifetime and the connection is reused forever. // Default 5 minutes ConnMaxLifetime time.Duration // Set the maximum number of concurrently open connections (in-use + idle) // Setting this to less than 0 will mean there is no maximum limit. // Default 25 MaxOpenConnections int // Set the maximum number of concurrently idle connections. Setting this // to less than 0 will mean that no idle connections are retained. // Default MaxOpenConnections MaxIdleConnections int // contains filtered or unexported fields }
MySQL 4.1+ see https://github.com/go-sql-driver/mysql/
func (MySQL) NetworkAddress ¶
type PostgreSQL ¶
type PostgreSQL struct { // Host (e.g. localhost) or absolute path to unix domain socket directory (e.g. /private/tmp) Host string Port int Database string Username string Password string // nil disables TLS TLSConfig *tls.Config ConnectTimeout time.Duration // e.g. net.Dialer.DialContext DialFunc pgconn.DialFunc // e.g. net.Resolver.LookupHost LookupFunc pgconn.LookupFunc BuildFrontend pgconn.BuildFrontendFunc // Run-time parameters to set on connection as session default values (e.g. search_path or application_name) RuntimeParams map[string]string Fallbacks []*pgconn.FallbackConfig // ValidateConnect is called during a connection attempt after a successful authentication with the PostgreSQL server. // It can be used to validate that the server is acceptable. If this returns an error the connection is closed and the next // fallback config is tried. This allows implementing high availability behavior such as libpq does with target_session_attrs. ValidateConnect pgconn.ValidateConnectFunc // AfterConnect is called after ValidateConnect. It can be used to set up the connection (e.g. Set session variables // or prepare statements). If this returns an error the connection attempt fails. AfterConnect pgconn.AfterConnectFunc // OnNotice is a callback function called when a notice response is received. OnNotice pgconn.NoticeHandler // OnNotification is a callback function called when a notification from the LISTEN/NOTIFY system is received. OnNotification pgconn.NotificationHandler // When the open connection limit is reached, and all connections are in-use, // any new database tasks that your application needs to execute will be forced // to wait until a connection becomes free and marked as idle. To mitigate this // you can set a fixed, fast, timeout when making database calls. // Default 10 seconds QueryTimeout time.Duration // Set the maximum lifetime of a connection to 1 hour. Setting it to 0 means // that there is no maximum lifetime and the connection is reused forever. // Default 5 minutes ConnMaxLifetime time.Duration // Set the maximum number of concurrently open connections (in-use + idle) // Setting this to less than 0 will mean there is no maximum limit. // Default 25 MaxOpenConnections int // Set the maximum number of concurrently idle connections. Setting this // to less than 0 will mean that no idle connections are retained. // Default MaxOpenConnections MaxIdleConnections int // contains filtered or unexported fields }
func (*PostgreSQL) Open ¶
func (m *PostgreSQL) Open() error
func (PostgreSQL) Pool ¶
func (m PostgreSQL) Pool() *sql.DB
func (PostgreSQL) Timeout ¶
func (m PostgreSQL) Timeout() time.Duration
Click to show internal directories.
Click to hide internal directories.