psql

package
v0.4.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2022 License: ISC Imports: 6 Imported by: 1

Documentation

Overview

Package sqldb interfaces database/sql

Index

Constants

This section is empty.

Variables

View Source
var DBFactory = &dbFactory{}

Functions

func DelFromContext

func DelFromContext(ctx context.Context, key string) (ok bool)

DelFromContext removes a value from context. Thread-safe

func DiscardDB

func DiscardDB(ctx context.Context)

DiscardDB removes db handle from context

func ExecValues added in v0.4.14

func ExecValues(execResult sql.Result, e error) (ID, rows int64, err error)

ExecValues parses the result from an Exec* method into its values. if LastInsertId or RowsAffected fails, the error is added to err.

func GetDB

func GetDB(ctx context.Context) (db *sql.DB)

GetDB obtains db handle from context

func NewExecResult added in v0.4.14

func NewExecResult(execResult sql.Result, e error) (result parl.ExecResult, err error)

func ScanToInt added in v0.4.14

func ScanToInt(sqlRow *sql.Row, e error) (value int, err error)

func StoreDB

func StoreDB(ctx context.Context, db *sql.DB)

StoreDB saves db handle in context

func StoreInContext

func StoreInContext(ctx context.Context, key string, value interface{}) (ok bool)

StoreInContext stores a value in context. Thread-safe

Types

type Context

type Context struct {
	context.Context
	Map sync.Map
}

Context is a context.Context with a Value() implementation

func NewContext

func NewContext(ctx ...context.Context) (c *Context)

NewContext provides a context.Context with a Value() implementation

func (*Context) Delete

func (c *Context) Delete(key string)

StoreInContext stores a value in context. Thread-safe

func (*Context) Store

func (c *Context) Store(key string, value interface{})

StoreInContext stores a value in context. Thread-safe

func (*Context) Value

func (c *Context) Value(key interface{}) (result interface{})

Value retrieves data from context. Thread-safe

func (*Context) Value2

func (c *Context) Value2(key interface{}) (result interface{}, ok bool)

Value2 retrieves data and was–present indicator from context. Thread-safe

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)

func (*DBCache) Close added in v0.4.14

func (dc *DBCache) Close() (err error)

func (*DBCache) Stmt added in v0.4.14

func (dc *DBCache) Stmt(query string, ctx context.Context) (stmt *sql.Stmt, err error)

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) Close added in v0.4.14

func (dm *DBMap) Close() (err error)

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)

func (*DBMap) Query added in v0.4.14

func (dm *DBMap) Query(
	partition parl.DBPartition, query string, ctx context.Context,
	args ...any) (sqlRows *sql.Rows, err error)

func (*DBMap) QueryInt added in v0.4.14

func (dm *DBMap) QueryInt(
	partition parl.DBPartition, query string, ctx context.Context,
	args ...any) (value int, err error)

func (*DBMap) QueryRow added in v0.4.14

func (dm *DBMap) QueryRow(
	partition parl.DBPartition, query string, ctx context.Context,
	args ...any) (sqlRow *sql.Row, err error)

func (*DBMap) QueryString added in v0.4.14

func (dm *DBMap) QueryString(
	partition parl.DBPartition, query string, ctx context.Context,
	args ...any) (value string, 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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL