Documentation ¶
Index ¶
- Variables
- func ColumnArray(m []map[string]interface{}, key string) []interface{}
- func ColumnArrayNil(m []map[string]interface{}, key string) []interface{}
- func ColumnFilter(m []map[string]interface{}, f func(string) bool) []map[string]interface{}
- type DB
- func (T *DB) Close() error
- func (T *DB) Exec(tx *sql.Tx, sqlstr string, args ...interface{}) (result sql.Result, err error)
- func (T *DB) ExecContext(ctx context.Context, tx *sql.Tx, sqlstr string, args ...interface{}) (result sql.Result, err error)
- func (T *DB) Has(sqlstr string, args ...interface{}) error
- func (T *DB) HasContext(ctx context.Context, sqlstr string, args ...interface{}) error
- func (T *DB) Logf(format string, a ...interface{})
- func (T *DB) Open(driverName, dataSourceName string) (*DB, error)
- func (T *DB) Query(tx *sql.Tx, sqlstr string, args ...interface{}) (data []map[string]interface{}, err error)
- func (T *DB) QueryContext(ctx context.Context, tx *sql.Tx, sqlstr string, args ...interface{}) (data []map[string]interface{}, err error)
- func (T *DB) QueryRow(tx *sql.Tx, sqlstr string, args ...interface{}) Rower
- func (T *DB) QueryRowContext(ctx context.Context, tx *sql.Tx, sqlstr string, args ...interface{}) Rower
- func (T *DB) TxBegin() (tx *sql.Tx, commit func(*error), err error)
- func (T *DB) TxCommit(tx *sql.Tx, e *error)
- type Rower
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TypeToContextKey = &contextKey{"TypeTo"} DataToContextKey = &contextKey{"DataTo"} )
Functions ¶
func ColumnArray ¶
以数组形式返回key列的值
m []map[string]interface{} 数据库的数据 key string key键名 []interface{} 返回key对应的值,不包含nil值
func ColumnArrayNil ¶
以数组形式返回key列的值
m []map[string]interface{} 数据库的数据 key string key键名 []interface{} 返回key对应的值,包含nil值
Types ¶
type DB ¶
type DB struct { *sql.DB Timeout time.Duration FormatColumnName bool // 将例名 AbcDf => abcDf TypeTo func(*sql.ColumnType) reflect.Type DataTo func(string, interface{}) interface{} ErrorLog *log.Logger DebugPrint bool DebugResult func(tx *sql.Tx, ctx context.Context, sqlstr string, args ...interface{}) interface{} // contains filtered or unexported fields }
说明:https://github.com/lib/pq/blob/master/doc.go postgresql://[user[:password]@][netloc][:port][,...][/dbname][?param1=value1&...]
func (*DB) ExecContext ¶
func (*DB) HasContext ¶
func (*DB) Query ¶
func (T *DB) Query(tx *sql.Tx, sqlstr string, args ...interface{}) (data []map[string]interface{}, err error)
支持读取/写入,支持返回错误:error, nil, ErrNoRows
func (*DB) QueryContext ¶
func (*DB) QueryRowContext ¶
Click to show internal directories.
Click to hide internal directories.