Documentation ¶
Index ¶
- func Connect(ctx context.Context, driver, dsn string, connOpts *ConnectOptions) (*sqlx.DB, error)
- type ConnectOptions
- type DB
- func (db *DB) Begin() (*sql.Tx, error)
- func (db *DB) Beginx() (*sqlx.Tx, error)
- func (db *DB) BindNamed(query string, arg interface{}) (string, interface{}, error)
- func (db *DB) Close() error
- func (db *DB) Exec(query string, args ...interface{}) (sql.Result, error)
- func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (db *DB) Follower() *sqlx.DB
- func (db *DB) Get(dest interface{}, query string, args ...interface{}) error
- func (db *DB) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (db *DB) Leader() *sqlx.DB
- func (db *DB) Named(query string, arg interface{}) (string, interface{}, error)
- func (db *DB) NamedExec(query string, arg interface{}) (sql.Result, error)
- func (db *DB) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
- func (db *DB) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
- func (db *DB) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (db *DB) QueryRow(query string, args ...interface{}) *sql.Row
- func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (db *DB) Rebind(query string) string
- func (db *DB) Select(dest interface{}, query string, args ...interface{}) error
- func (db *DB) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (db *DB) SetConnMaxLifetime(t time.Duration)
- func (db *DB) SetMaxIdleConns(n int)
- func (db *DB) SetMaxOpenConns(n int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnectOptions ¶
type ConnectOptions struct { Retry int MaxOpenConnections int MaxIdleConnections int ConnectionMaxLifetime time.Duration }
ConnectOptions to list options when connect to the db
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB struct to hold all database connections
func Wrap ¶
Wrap leader and follower sqlx object to one DB object this is for easier usage, so user doesn't have to specify leader or follower all exec is going to leader, all query is going to follower
func (*DB) ExecContext ¶
func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
ExecContext function
func (*DB) GetContext ¶
func (db *DB) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
GetContext function
func (*DB) NamedExecContext ¶
func (db *DB) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
NamedExecContext function
func (*DB) NamedQuery ¶
NamedQuery function
func (*DB) QueryContext ¶
func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryContext function
func (*DB) QueryRowContext ¶
QueryRowContext function
func (*DB) SelectContext ¶
func (db *DB) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
SelectContext fuction
func (*DB) SetConnMaxLifetime ¶
SetConnMaxLifetime to sql database
Click to show internal directories.
Click to hide internal directories.