clickhousex

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColumnsMatch

func ColumnsMatch(cs1, cs2 []*Column) bool

func CreateDbClusterIne

func CreateDbClusterIne(dsn, cluster string) error

func CreateDbIne

func CreateDbIne(dsn string) error

func CreateTempTable

func CreateTempTable(shards [][]string, db, table string) (string, error)

func DropTable

func DropTable(c sqlx.SqlConn, table string) error

func DropTableClusterIe

func DropTableClusterIe(c sqlx.SqlConn, cluster, db, table string) error

func DropTableIe

func DropTableIe(c sqlx.SqlConn, table string) error

func ExecClusterAllReplicas

func ExecClusterAllReplicas(shards [][]string, retry int, f func(dsn string) error) error

func ExecClusterAnyShard

func ExecClusterAnyShard(shards [][]string, retry int, f func(dsn string) error) error

func ExecClusterEachShards

func ExecClusterEachShards(shards [][]string, retry int, f func(dsn string) error) error

func ExecClusterEachShardsAll

func ExecClusterEachShardsAll(shards [][]string, retry int, f func(dsn string) error) error

func ExecWithRetry

func ExecWithRetry(dsn string, retry int, f func(dsn string) error) error

func GetCreateTableQuery

func GetCreateTableQuery(c sqlx.SqlConn, db, table string) (string, error)

func GetLengthTag

func GetLengthTag(field reflect.StructField) (int, error)

func RenameTable

func RenameTable(c sqlx.SqlConn, table, to string) error

func ShowDatabases

func ShowDatabases(c sqlx.SqlConn) ([]string, error)

func ShowTables

func ShowTables(c sqlx.SqlConn) ([]string, error)

func TableExists

func TableExists(c sqlx.SqlConn, table string) (bool, error)

func TakeClient

func TakeClient(dsn string) (*sql.DB, error)

func TakeClientx

func TakeClientx(dsn string) sqlx.SqlConn

func TruncateTable

func TruncateTable(c sqlx.SqlConn, table string) error

Types

type ClickHouseClusterModel

type ClickHouseClusterModel struct {
	Conn      sqlx.SqlConn
	AppName   string
	Dsn       string
	Shards    [][]string
	Database  string
	Cluster   string
	TableName string
	Type      reflect.Type
	Indexes   []string

	InsertIDKey string
	FlagKey     string
	FieldDBs    []string
	FieldNames  []string
	// contains filtered or unexported fields
}

func MustNewClickHouseClusterModel

func MustNewClickHouseClusterModel(appName, dsn, cluster string, data interface{}, shards [][]string) (*ClickHouseClusterModel, error)

MustNewClickHouseClusterModel 按照data结构体新建model,如果表存在,则删掉重新创建

func NewClickHouseClusterModel

func NewClickHouseClusterModel(appName, dsn, cluster string, data interface{}, shards [][]string) (*ClickHouseClusterModel, error)

NewClickHouseClusterModel 按照data结构体新建model,如果表不存在,则自动创建

func (*ClickHouseClusterModel) All

func (c *ClickHouseClusterModel) All() (interface{}, error)

func (*ClickHouseClusterModel) BatchInsert

func (c *ClickHouseClusterModel) BatchInsert(vs interface{}) error

func (*ClickHouseClusterModel) DeleteWhere

func (c *ClickHouseClusterModel) DeleteWhere(where string, args ...interface{}) error

func (*ClickHouseClusterModel) DropTableIfExists

func (c *ClickHouseClusterModel) DropTableIfExists() error

func (*ClickHouseClusterModel) MustAll

func (c *ClickHouseClusterModel) MustAll() interface{}

func (*ClickHouseClusterModel) QueryWhere

func (c *ClickHouseClusterModel) QueryWhere(where string, args ...interface{}) (interface{}, error)

type Cluster

type Cluster struct {
	QueryNode string
	Shards    [][]string
	Name      string
}

type Column

type Column struct {
	Name              string `db:"name"`
	Type              string `db:"type"`
	DefaultValue      string `db:"default_value"`
	DefaultExpression string `db:"default_expression"`
	Comment           string `db:"comment"`
	CodecExpression   string `db:"codec_expression"`
	TTLExpression     string `db:"ttl_expression"`
}

func DescribeTable

func DescribeTable(conn sqlx.SqlConn, table string) ([]*Column, error)

DescribeTable 新建clickhouse table信息

type CreateTableQuery

type CreateTableQuery struct {
	CreateTableQuery string `db:"create_table_query"`
}

type Name

type Name struct {
	Name string `db:"name"`
}

Jump to

Keyboard shortcuts

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