Documentation
¶
Overview ¶
Package sqldb interfaces database/sql
Index ¶
- Variables
- func DelFromContext(ctx context.Context, key string) (ok bool)
- func DiscardDB(ctx context.Context)
- func ExecValues(execResult sql.Result, e error) (ID, rows int64, err error)
- func GetDB(ctx context.Context) (db *sql.DB)
- func NewExecResult(execResult sql.Result, e error) (result parl.ExecResult, err error)
- func ScanToInt(sqlRow *sql.Row, e error) (value int, err error)
- func StoreDB(ctx context.Context, db *sql.DB)
- func StoreInContext(ctx context.Context, key string, value interface{}) (ok bool)
- type Context
- type DBCache
- type DBMap
- func (dm *DBMap) Close() (err error)
- func (dm *DBMap) Exec(partition parl.DBPartition, query string, ctx context.Context, args ...any) (execResult parl.ExecResult, err error)
- func (dm *DBMap) Query(partition parl.DBPartition, query string, ctx context.Context, args ...any) (sqlRows *sql.Rows, err error)
- func (dm *DBMap) QueryInt(partition parl.DBPartition, query string, ctx context.Context, args ...any) (value int, err error)
- func (dm *DBMap) QueryRow(partition parl.DBPartition, query string, ctx context.Context, args ...any) (sqlRow *sql.Row, err error)
- func (dm *DBMap) QueryString(partition parl.DBPartition, query string, ctx context.Context, args ...any) (value string, err error)
- type ExecResult
Constants ¶
This section is empty.
Variables ¶
var DBFactory = &dbFactory{}
Functions ¶
func DelFromContext ¶
DelFromContext removes a value from context. Thread-safe
func ExecValues ¶ added in v0.4.14
ExecValues parses the result from an Exec* method into its values. if LastInsertId or RowsAffected fails, the error is added to err.
func NewExecResult ¶ added in v0.4.14
Types ¶
type Context ¶
Context is a context.Context with a Value() implementation
func NewContext ¶
NewContext provides a context.Context with a Value() implementation
type DBCache ¶ added in v0.4.14
type DBCache struct {
// contains filtered or unexported fields
}
func NewDBCache ¶ added in v0.4.14
func NewDBCache(dataSource parl.DataSource) (dc *DBCache)
type DBMap ¶ added in v0.4.14
type DBMap struct {
// contains filtered or unexported fields
}
func NewDBMap ¶ added in v0.4.14
func NewDBMap(dsnr parl.DataSourceNamer, schema func(dataSource parl.DataSource, ctx context.Context) (err error)) (dbMap *DBMap)
func (*DBMap) Exec ¶ added in v0.4.14
func (dm *DBMap) Exec( partition parl.DBPartition, query string, ctx context.Context, args ...any) (execResult parl.ExecResult, err error)
type ExecResult ¶ added in v0.4.14
type ExecResult struct { ID int64 // contains filtered or unexported fields }
ExecResult makes sql.Result printable. sql.Result are obtained by invoking Exec* methods of sql.DB sql.Stmt sql.Conn sql.Tx. sql.Result is an interface with methods LastInsertId and RowsAffected. each driver provides an sql.Result implementation.
func (*ExecResult) Get ¶ added in v0.4.14
func (r *ExecResult) Get() (ID int64, rows int64)
Get obtains last id and number of affected rows with errors separately
func (ExecResult) String ¶ added in v0.4.14
func (r ExecResult) String() (s string)