CorePostgres

package
v5.1.38 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	//DB 数据库对象
	DB *sqlx.DB
	//InstallDir 配置文件默认路径
	InstallDir string
	//最大连接数量
	MaxConnect int
	//连接超时时间秒
	ConnectExpireSec int
}

func (*Client) Exec

func (t *Client) Exec(query string, args ...any) (s sql.Result, err error)

Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.

Exec uses context.Background internally; to specify the context, use ExecContext.

func (*Client) Get

func (t *Client) Get(dest interface{}, query string, args ...interface{}) (err error)

Get using this DB. Any placeholder parameters are replaced with supplied args. An error is returned if the result set is empty.

func (*Client) Init

func (t *Client) Init(url string, installDir string, timeZone string) (err error)

Init 初始化 eg url: host=%s port=%d user=%s password=%s dbname=%s sslmode=disable

func (*Client) Install

func (t *Client) Install() (err error)

Install 自动安装配置文件

func (*Client) MustBegin

func (t *Client) MustBegin() *sqlx.Tx

MustBegin starts a transaction, and panics on error. Returns an *sqlx.Tx instead of an *sql.Tx.

func (*Client) NamedExec

func (t *Client) NamedExec(query string, arg interface{}) (s sql.Result, err error)

NamedExec using this DB. Any named placeholder parameters are replaced with fields from arg.

func (*Client) Ping

func (t *Client) Ping() (err error)

Ping verifies a connection to the database is still alive, establishing a connection if necessary.

Ping uses context.Background internally; to specify the context, use PingContext.

func (*Client) PrepareNamed

func (t *Client) PrepareNamed(query string) (s *sqlx.NamedStmt, err error)

PrepareNamed returns an sqlx.NamedStmt

func (*Client) Select

func (t *Client) Select(dest interface{}, query string, args ...interface{}) (err error)

Select using this DB. Any placeholder parameters are replaced with supplied args.

Jump to

Keyboard shortcuts

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