Documentation
¶
Index ¶
- Constants
- Variables
- type DB
- func (db DB) Begin() (*Tx, error)
- func (db DB) Beginx() (*Tx, error)
- func (db DB) Get(dest interface{}, query string, args ...interface{}) error
- func (db DB) NamedExec(query string, arg interface{}) (sql.Result, error)
- func (db DB) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (db DB) QueryRow(query string, args ...interface{}) *sql.Row
- func (db DB) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (db DB) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- func (db *DB) ResetDB()
- func (db *DB) ResetTables()
- func (db DB) Select(dest interface{}, query string, args ...interface{}) error
- type PostgresDBOpts
- type Querier
- type Timer
- type Tx
- func (tx Tx) Get(dest interface{}, query string, args ...interface{}) error
- func (tx Tx) NamedExec(query string, arg interface{}) (sql.Result, error)
- func (tx Tx) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (tx Tx) QueryRow(query string, args ...interface{}) *sql.Row
- func (tx Tx) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (tx Tx) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- func (tx Tx) Select(dest interface{}, query string, args ...interface{}) error
Constants ¶
View Source
const ( ENV_VAR_NAME_DISABLED = "LONG_QUERY_LOGGING_OFF" ENV_VAR_NAME_THRESHOLD = "LONG_QUERY_THRESHOLD_SECS" DEFAULT_LONG_QUERY_THRESHOLD_SECS = 10 )
View Source
const DefaultStatementTimeout = 5 * time.Minute
Variables ¶
View Source
var ( LongQueryThresholdSecs int LoggingDisabled bool Logger *logrus.Entry )
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB exposes all the methods available on the *sqlx.DB struct
func NewPostgresDB ¶
func NewPostgresDB(opts *PostgresDBOpts) (DB, error)
func (*DB) ResetDB ¶
func (db *DB) ResetDB()
Many packages use the same schema, this function knows which order to clear out tables so each package doesn't need to know (given foreign key constraints, etc)
func (*DB) ResetTables ¶
func (db *DB) ResetTables()
Many packages use the same schema, this function knows which order to clear out tables so each package doesn't need to know (given foreign key constraints, etc)
type PostgresDBOpts ¶
type PostgresDBOpts struct { Host string Port string User string Password string Database string Driver string MaxOpenConns int MaxIdleConns int StatementTimeout time.Duration }
func LocalOpts ¶
func LocalOpts() *PostgresDBOpts
func MustGetOpts ¶
func MustGetOpts() *PostgresDBOpts
MustGetOpts gets database configuration from the environment. Panics if any configuration items are missing.
func MustGetOptsWithMaxConns ¶
func MustGetOptsWithMaxConns(maxOpenConns int, maxIdleConns int) *PostgresDBOpts
type Querier ¶
type Querier interface { Exec(query string, args ...interface{}) (sql.Result, error) Select(dest interface{}, query string, args ...interface{}) error SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error Get(dest interface{}, query string, args ...interface{}) error Rebind(query string) string QueryRow(query string, args ...interface{}) *sql.Row QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row Query(query string, args ...interface{}) (*sql.Rows, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) }
Querier is an interface which is implemented by both *sqlx.DB and *sqlx.Tx
Click to show internal directories.
Click to hide internal directories.