Documentation ¶
Index ¶
- Constants
- func AddMigrationProvider(name string, provider MigrationProvider)
- func IsDuplicateEntryError(err error) bool
- func NewConnectionFromSettings(logger log.Logger, settings Settings) (*sqlx.DB, error)
- func NewConnectionWithInterfaces(logger log.Logger, settings Settings) (*sqlx.DB, error)
- func ProvideConnection(config cfg.Config, logger log.Logger, configKey string) (*sqlx.DB, error)
- type Client
- type ClientSqlx
- func (c *ClientSqlx) BeginTx(ctx context.Context, ops *sql.TxOptions) (*sql.Tx, error)
- func (c *ClientSqlx) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (c *ClientSqlx) ExecMultiInTx(ctx context.Context, sqlers ...Sqler) (results []sql.Result, err error)
- func (c *ClientSqlx) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (c *ClientSqlx) GetResult(ctx context.Context, query string, args ...interface{}) (*Result, error)
- func (c *ClientSqlx) GetSingleScalarValue(ctx context.Context, query string, args ...interface{}) (int, error)
- func (c *ClientSqlx) Prepare(ctx context.Context, query string) (*sql.Stmt, error)
- func (c *ClientSqlx) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (c *ClientSqlx) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (c *ClientSqlx) Queryx(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
- func (c *ClientSqlx) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (c *ClientSqlx) WithTx(ctx context.Context, ops *sql.TxOptions, ...) (err error)
- type Driver
- type DriverFactory
- type DuplicateEntryError
- type MigrationProvider
- type MigrationSettings
- type QueryBuilder
- type RawQueryBuilder
- func (b *RawQueryBuilder) GroupBy(field ...string) QueryBuilder
- func (b *RawQueryBuilder) Joins(joins []string) QueryBuilder
- func (b *RawQueryBuilder) OrderBy(field string, direction string) QueryBuilder
- func (b *RawQueryBuilder) Page(offset int, size int) QueryBuilder
- func (b *RawQueryBuilder) Table(table string) QueryBuilder
- func (b *RawQueryBuilder) Where(query interface{}, args ...interface{}) QueryBuilder
- type Result
- type ResultRow
- type Settings
- type SettingsTimeout
- type SqlResult
- type Sqler
- type Uri
Constants ¶
View Source
const DriverMysql = "mysql"
View Source
const DriverNameCrateDb = "cratedb"
View Source
const DriverNameRedshift = "redshift"
View Source
const (
FormatDateTime = "2006-01-02 15:04:05"
)
Variables ¶
This section is empty.
Functions ¶
func AddMigrationProvider ¶ added in v0.18.0
func AddMigrationProvider(name string, provider MigrationProvider)
func IsDuplicateEntryError ¶
Types ¶
type Client ¶
type Client interface { GetSingleScalarValue(ctx context.Context, query string, args ...interface{}) (int, error) GetResult(ctx context.Context, query string, args ...interface{}) (*Result, error) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) ExecMultiInTx(ctx context.Context, sqlers ...Sqler) (results []sql.Result, err error) Prepare(ctx context.Context, query string) (*sql.Stmt, error) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) Queryx(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error WithTx(ctx context.Context, ops *sql.TxOptions, do func(ctx context.Context, tx *sql.Tx) error) error }
type ClientSqlx ¶
type ClientSqlx struct {
// contains filtered or unexported fields
}
func (*ClientSqlx) ExecMultiInTx ¶ added in v0.19.4
func (*ClientSqlx) Get ¶
func (c *ClientSqlx) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
func (*ClientSqlx) GetSingleScalarValue ¶
type Driver ¶ added in v0.19.4
type Driver interface { GetDSN(settings Settings) string GetMigrationDriver(db *sql.DB, database string, migrationsTable string) (database.Driver, error) }
type DuplicateEntryError ¶
type DuplicateEntryError struct {
Err error
}
func (*DuplicateEntryError) As ¶
func (e *DuplicateEntryError) As(target interface{}) bool
func (*DuplicateEntryError) Error ¶
func (e *DuplicateEntryError) Error() string
func (*DuplicateEntryError) Is ¶
func (e *DuplicateEntryError) Is(err error) bool
func (*DuplicateEntryError) Unwrap ¶
func (e *DuplicateEntryError) Unwrap() error
type MigrationProvider ¶ added in v0.18.0
type MigrationSettings ¶
type QueryBuilder ¶
type QueryBuilder interface { Table(table string) QueryBuilder Joins(joins []string) QueryBuilder Where(query interface{}, args ...interface{}) QueryBuilder GroupBy(field ...string) QueryBuilder OrderBy(field string, direction string) QueryBuilder Page(offset int, size int) QueryBuilder }
type RawQueryBuilder ¶
type RawQueryBuilder struct {
Builder squirrel.SelectBuilder
}
func NewQueryBuilder ¶
func NewQueryBuilder() *RawQueryBuilder
func (*RawQueryBuilder) GroupBy ¶
func (b *RawQueryBuilder) GroupBy(field ...string) QueryBuilder
func (*RawQueryBuilder) Joins ¶
func (b *RawQueryBuilder) Joins(joins []string) QueryBuilder
func (*RawQueryBuilder) OrderBy ¶
func (b *RawQueryBuilder) OrderBy(field string, direction string) QueryBuilder
func (*RawQueryBuilder) Page ¶
func (b *RawQueryBuilder) Page(offset int, size int) QueryBuilder
func (*RawQueryBuilder) Table ¶
func (b *RawQueryBuilder) Table(table string) QueryBuilder
func (*RawQueryBuilder) Where ¶
func (b *RawQueryBuilder) Where(query interface{}, args ...interface{}) QueryBuilder
type Settings ¶
type Settings struct { Charset string `cfg:"charset" default:"utf8mb4"` Collation string `cfg:"collation" default:"utf8mb4_general_ci"` ConnectionMaxIdleTime time.Duration `cfg:"connection_max_idletime" default:"120s"` ConnectionMaxLifetime time.Duration `cfg:"connection_max_lifetime" default:"120s"` Driver string `cfg:"driver"` MaxIdleConnections int `cfg:"max_idle_connections" default:"2"` // 0 or negative number=no idle connections, sql driver default=2 MaxOpenConnections int `cfg:"max_open_connections" default:"0"` // 0 or negative number=unlimited, sql driver default=0 Migrations MigrationSettings `cfg:"migrations"` MultiStatements bool `cfg:"multi_statements" default:"true"` ParseTime bool `cfg:"parse_time" default:"true"` Timeouts SettingsTimeout `cfg:"timeouts"` Uri Uri `cfg:"uri"` }
type SettingsTimeout ¶ added in v0.19.4
type SettingsTimeout struct { ReadTimeout time.Duration `cfg:"readTimeout" default:"0"` // I/O read timeout. The value must be a decimal number with a unit suffix ("ms", "s", "m", "h"), such as "30s", "0.5m" or "1m30s". WriteTimeout time.Duration `cfg:"writeTimeout" default:"0"` // I/O write timeout. The value must be a decimal number with a unit suffix ("ms", "s", "m", "h"), such as "30s", "0.5m" or "1m30s". Timeout time.Duration `cfg:"timeout" default:"0"` // Timeout for establishing connections, aka dial timeout. The value must be a decimal number with a unit suffix ("ms", "s", "m", "h"), such as "30s", "0.5m" or "1m30s". }
type Uri ¶
type Uri struct { Host string `cfg:"host" default:"localhost" validation:"required"` Port int `cfg:"port" default:"3306" validation:"required"` User string `cfg:"user" validation:"required"` Password string `cfg:"password" validation:"required"` Database string `cfg:"database" validation:"required"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.