Documentation ¶
Index ¶
- func BuildDBDriver(opts *Options) string
- type Count
- type DBConnect
- func (db *DBConnect) Exec(ctx context.Context, query string, args ...any) (lastInsertId, rowsAffected int64, err error)
- func (db *DBConnect) Query(ctx context.Context, query string, args ...any) (results []map[string]any, count int64, err error)
- func (db *DBConnect) Select(ctx context.Context, dest any, query string, args ...any) (count int64, err error)
- func (db *DBConnect) SelectOne(ctx context.Context, dest any, query string, args ...any) (err error)
- type Map
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDBDriver ¶
BuildDBDriver return a driver like "user:pass@tcp(host:port)/dbName?charset=utf8&loc=Asia%%2FShanghai"
Types ¶
type DBConnect ¶
type DBConnect struct { *sql.DB Options *Options ContextTx contextKey // contains filtered or unexported fields }
func (*DBConnect) Exec ¶
func (db *DBConnect) Exec(ctx context.Context, query string, args ...any) (lastInsertId, rowsAffected int64, err error)
Exec exec query by prepare sql, eg: INSERT, UPDATE, DELETE
func (*DBConnect) Query ¶
func (db *DBConnect) Query(ctx context.Context, query string, args ...any) (results []map[string]any, count int64, err error)
Query query by prepare sql, eg: SELECT
type Option ¶
type Option func(opts *Options)
func WithCharset ¶
func WithDBName ¶
func WithPoolSize ¶
Click to show internal directories.
Click to hide internal directories.