cockroach

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func (*Conn) BulkInsert

func (this *Conn) BulkInsert(cmd string, nCol int, args ...interface{}) error

insert many records at one shot. often insert many logs. values := make([]interface{}, 0, batchsize*nCol) conn.BulkInsert("insert into files(bucket,filename)", nCol, values...)

func (*Conn) BulkInsertEx

func (this *Conn) BulkInsertEx(cmd string, nCol int, args []interface{}, szSQLsurfix ...string) error

conn.BulkInsertEx("insert into msgs(fid, username, area)", nColumn, values, "ON CONFLICT(fid) DO NOTHING") reference: INSERT INTO ON CONFLICT(id) DO NOTHING reference: INSERT INTO ON CONFLICT(sn,orgid) DO UPDATE SET status=excluded.status reference: INSERT INTO ON CONFLICT(id) DO UPDATE SET (status,name)=(excluded.status,excluded.name)

func (*Conn) Close

func (this *Conn) Close() error

func (*Conn) Context

func (this *Conn) Context() context.Context

func (*Conn) Exec

func (this *Conn) Exec(cmd string, args ...interface{}) error

insert update delete create table, alter index etc.

func (*Conn) Ping

func (this *Conn) Ping() error

func (*Conn) Query

func (this *Conn) Query(query string, args ...interface{}) (QArray, error)

query database

func (*Conn) QueryCount

func (this *Conn) QueryCount(query string, args ...interface{}) (int64, error)

select count(*) from ...

func (*Conn) Select

func (this *Conn) Select(dest interface{}, query string, args ...interface{}) error

query database

func (*Conn) WithContext

func (this *Conn) WithContext(ctx context.Context) *Conn

type DBServer

type DBServer struct {
	// contains filtered or unexported fields
}

func New

func New(dataSourceName string, MaxIdleConn int) (*DBServer, error)

"postgresql://root@127.0.0.1:26257/bank?sslmode=disable"

func (*DBServer) Close

func (this *DBServer) Close()

func (*DBServer) ExecInTx

func (this *DBServer) ExecInTx(fn func(*Conn) error) error

func (*DBServer) ExecInTxContext

func (this *DBServer) ExecInTxContext(ctx context.Context, fn func(*Conn) error) error

func (*DBServer) NewConn

func (this *DBServer) NewConn() *Conn

type QArray

type QArray []QItem

func MakeQArray

func MakeQArray() QArray

func (*QArray) Base64Encode

func (array *QArray) Base64Encode(key ...string) *QArray

func (*QArray) IntToBool

func (array *QArray) IntToBool(key ...string) *QArray

func (*QArray) Shuffle

func (array *QArray) Shuffle() *QArray

func (*QArray) ToFloat64

func (array *QArray) ToFloat64(key ...string) *QArray

func (*QArray) ToInt64

func (array *QArray) ToInt64(key ...string) *QArray

func (*QArray) ToRawArray

func (array *QArray) ToRawArray() []interface{}

type QItem

type QItem map[string]interface{}

func (QItem) AsMap

func (item QItem) AsMap() map[string]interface{}

func (QItem) Base64Encode

func (item QItem) Base64Encode(keys ...string) QItem

func (QItem) GetColumnFloat64

func (item QItem) GetColumnFloat64(key string) float64

func (QItem) GetColumnInt64

func (item QItem) GetColumnInt64(key string) int64

func (QItem) GetColumnString

func (item QItem) GetColumnString(key string) string

func (QItem) IntToBool

func (item QItem) IntToBool(keys ...string) QItem

func (QItem) ToFloat64

func (item QItem) ToFloat64(keys ...string) QItem

func (QItem) ToInt64

func (item QItem) ToInt64(keys ...string) QItem

type TableWatcher

type TableWatcher struct {
	// contains filtered or unexported fields
}

func NewTableWatcher

func NewTableWatcher(dataSourceName string) (*TableWatcher, error)

func (*TableWatcher) Close

func (this *TableWatcher) Close() error

func (*TableWatcher) WatchTables

func (this *TableWatcher) WatchTables(tables []string, tmBegin time.Time, key_only bool, callback func(tbl string, keys string, records string)) error

type TxCompatible

type TxCompatible struct {
	*sqlx.Tx
}

func (*TxCompatible) Commit

func (t *TxCompatible) Commit(context.Context) error

func (*TxCompatible) Exec

func (t *TxCompatible) Exec(ctx context.Context, query string, args ...interface{}) error

func (*TxCompatible) Rollback

func (t *TxCompatible) Rollback(context.Context) error

Jump to

Keyboard shortcuts

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