Documentation ¶
Index ¶
- type Client
- func (t *Client) Exec(query string, args ...any) (s sql.Result, err error)
- func (t *Client) Get(dest interface{}, query string, args ...interface{}) (err error)
- func (t *Client) Init(url string, installDir string, timeZone string) (err error)
- func (t *Client) Install() (err error)
- func (t *Client) MustBegin() *sqlx.Tx
- func (t *Client) NamedExec(query string, arg interface{}) (s sql.Result, err error)
- func (t *Client) Ping() (err error)
- func (t *Client) PrepareNamed(query string) (s *sqlx.NamedStmt, err error)
- func (t *Client) Select(dest interface{}, query string, args ...interface{}) (err error)
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 ¶
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 ¶
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 ¶
Init 初始化 eg url: host=%s port=%d user=%s password=%s dbname=%s sslmode=disable
func (*Client) MustBegin ¶
MustBegin starts a transaction, and panics on error. Returns an *sqlx.Tx instead of an *sql.Tx.
func (*Client) NamedExec ¶
NamedExec using this DB. Any named placeholder parameters are replaced with fields from arg.
func (*Client) Ping ¶
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 ¶
PrepareNamed returns an sqlx.NamedStmt