Documentation ¶
Index ¶
- func GetNextSQLID() uint64
- type Config
- type DB
- func (db *DB) BeginTxx(ctx context.Context, externalId uint64, opts *sql.TxOptions) (tx *Tx, myerr error)
- func (db *DB) Beginx(externalId uint64) (tx *Tx, myerr error)
- func (db *DB) Close() (myerr error)
- func (db *DB) Commit(externalId uint64, tx *Tx) (myerr error)
- func (db *DB) Exec(externalId uint64, tx *Tx, sqlT string, args ...interface{}) (rowsAffected int64, lastInsertId int64, err error)
- func (db *DB) Get(externalId uint64, tx *Tx, sqlT string, dest interface{}, args ...interface{}) (exists bool, myerr error)
- func (db *DB) NamedExec(externalId uint64, tx *Tx, sqlT string, args interface{}) (rowsAffected int64, lastInsertId int64, myerr error)
- func (db *DB) PreparexAddSql(sql string, needPrepare bool) (myerr error)
- func (db *DB) PreparexAll(sqlStms SQLStms) (myerr error)
- func (db *DB) QueryRowScan(externalId uint64, tx *Tx, sqlT string, dest []interface{}, ...) (exists bool, myerr error)
- func (db *DB) QueryRowxStructScan(externalId uint64, tx *Tx, sqlT string, dest interface{}, args ...interface{}) (exists bool, myerr error)
- func (db *DB) Rollback(externalId uint64, tx *Tx) (myerr error)
- func (db *DB) Select(externalId uint64, tx *Tx, sqlT string, dest interface{}, args ...interface{}) (myerr error)
- type SQLStm
- type SQLStms
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Name string `yaml:"name" json:"name"` // имя подключения ConnectString string `yaml:"-" json:"-"` // строка подключения к БД Host string `yaml:"host" json:"host"` // host БД Port string `yaml:"port" json:"port"` // порт БД Dbname string `yaml:"dbname" json:"dbname"` // имя БД SslMode string `yaml:"ssl_mode" json:"ssl_mode"` // режим SSL User string `yaml:"user" json:"user"` // пользователь БД Pass string `yaml:"pass" json:"pass"` // пароль пользователя БД ConnMaxLifetime time.Duration `yaml:"conn_max_lifetime" json:"conn_max_lifetime"` // время жизни подключения в миллисекундах MaxOpenConns int `yaml:"max_open_conns" json:"max_open_conns"` // максимальное количество открытых подключений MaxIdleConns int `yaml:"max_idle_conns" json:"max_idle_conns"` // максимальное количество простаивающих подключений DriverName string `yaml:"driver_name" json:"driver_name"` // имя драйвера "postgres" | "pgx" | "godror" }
Config конфигурационные настройки БД
type DB ¶
DB is a wrapper around sqlx.DB
func (*DB) BeginTxx ¶
func (db *DB) BeginTxx(ctx context.Context, externalId uint64, opts *sql.TxOptions) (tx *Tx, myerr error)
BeginTxx - begin a new transaction
func (*DB) Exec ¶
func (db *DB) Exec(externalId uint64, tx *Tx, sqlT string, args ...interface{}) (rowsAffected int64, lastInsertId int64, err error)
Exec - represent common task in process DML statement
func (*DB) Get ¶
func (db *DB) Get(externalId uint64, tx *Tx, sqlT string, dest interface{}, args ...interface{}) (exists bool, myerr error)
Get - represent common task in process SQL Select statement with only one rows
func (*DB) NamedExec ¶
func (db *DB) NamedExec(externalId uint64, tx *Tx, sqlT string, args interface{}) (rowsAffected int64, lastInsertId int64, myerr error)
NamedExec - represent common task in process DML statement
func (*DB) PreparexAddSql ¶
PreparexAddSql - prepare SQL statements and add it to map
func (*DB) PreparexAll ¶
PreparexAll - prepare SQL statements
func (*DB) QueryRowScan ¶
func (db *DB) QueryRowScan(externalId uint64, tx *Tx, sqlT string, dest []interface{}, args ...interface{}) (exists bool, myerr error)
QueryRowScan - represent common task in process SQL Select statement with only one rows
func (*DB) QueryRowxStructScan ¶
func (db *DB) QueryRowxStructScan(externalId uint64, tx *Tx, sqlT string, dest interface{}, args ...interface{}) (exists bool, myerr error)
QueryRowxStructScan - represent common task in process SQL Select statement with only one rows
Click to show internal directories.
Click to hide internal directories.