Documentation ¶
Index ¶
- Variables
- type Count
- type DBConnect
- func (db *DBConnect) AllowExperimentalObjectType(enable bool) error
- func (db *DBConnect) Select(ctx context.Context, dest any, query string, args ...any) (count int64, err error)
- func (db *DBConnect) SelectAll(ctx context.Context, dest any, query string, args ...any) (count int64, err error)
- func (db *DBConnect) SelectMany(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 MultiSelect
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RegCount = regexp.MustCompile("(?is)^(SELECT).*?(FROM)") RegLimit = regexp.MustCompile(`(?is)LIMIT\s+(\d+|\?)(?:\s*,\s*(\d+|\?))*\s*$`) RegOrderLimit = regexp.MustCompile(`(?is)(ORDER BY \S+(\s+(ASC|DESC))?\s+)?LIMIT\s+(\d+|\?)(?:\s*,\s*(\d+|\?))*\s*$`) )
Functions ¶
This section is empty.
Types ¶
type DBConnect ¶
type DBConnect struct { clickhouse.Conn Options *clickhouse.Options }
func New ¶
New return a new clickhouse client, and try ping.
conn, err := clickhousebuilder.New(&clickhouse.Options{ Addr: []string{fmt.Sprintf("%s:%d", "localhost", 9000)}, Auth: clickhouse.Auth{ Database: "database", Username: "default", Password: "default", }, DialTimeout: time.Second, MaxOpenConns: 10, MaxIdleConns: 10 / 2, ConnMaxLifetime: time.Hour, })
func (*DBConnect) AllowExperimentalObjectType ¶
AllowExperimentalObjectType enable or disable object(json) type
func (*DBConnect) Select ¶
func (db *DBConnect) Select(ctx context.Context, dest any, query string, args ...any) (count int64, err error)
Select 查询数据
func (*DBConnect) SelectAll ¶
func (db *DBConnect) SelectAll(ctx context.Context, dest any, query string, args ...any) (count int64, err error)
SelectAll 返回所有数据,如果最后有 limit 会删除
Click to show internal directories.
Click to hide internal directories.