postgre

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: 9 Imported by: 0

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 DO NOTHING reference: INSERT INTO ON CONFLICT DO UPDATE

func (*Conn) BulkInsert_obsolete

func (this *Conn) BulkInsert_obsolete(cmd string, records [][]interface{}) error

insert many records at one shot. often insert many logs. DO NOT USE THIS, IT'IS SLOW

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 added in v1.1.0

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:5432/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

Jump to

Keyboard shortcuts

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