clickhouse

package module
v0.0.0-...-6aaef51 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 7 Imported by: 0

README

clickhouse

Go Report Card Build Status Coverage GoDoc

Golang client wrapper for ClickHouse.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigValidation = errors.New("clickhouse config validation error")

ErrConfigValidation is general config validation error message.

Functions

func PrepareInsertionSQL

func PrepareInsertionSQL(model Model) string

PrepareInsertionSQL prepares a SQL prepare statement to insert records into the database.

Types

type Config

type Config struct {
	Addr     string `json:"addr" yaml:"addr"`
	Database string `json:"database" yaml:"database"`
	Debug    bool   `json:"debug" yaml:"debug"`
	ZoneInfo string `json:"zone_info" yaml:"zoneinfo"`
}

Config contains config for ClickHouse database.

func (*Config) GetDSN

func (cfg *Config) GetDSN() string

GetDSN returns Data Source Name connection string to ClickHouse database.

func (Config) Validate

func (cfg Config) Validate() error

Validate checks required fields and validates for allowed values.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is a wrapper around sql.DB which keeps track of the ClickHouse database.

func NewDB

func NewDB(cfg *Config) (*DB, error)

NewDB creates new connection to ClickHouse using SQLX.

func (*DB) Close

func (db *DB) Close() error

Close closes connection to database.

func (*DB) Config

func (db *DB) Config() *Config

Config returns config.

func (*DB) DB

func (db *DB) DB() *sqlx.DB

DB returns pointer to sqlx.DB.

func (*DB) GetServerTime

func (db *DB) GetServerTime() (time.Time, error)

GetServerTime gets and returns database server time.

func (*DB) IsConnected

func (db *DB) IsConnected() bool

IsConnected checks connection status to database.

func (*DB) MultiInsert

func (db *DB) MultiInsert(query string, rows [][]interface{}) error

MultiInsert creates transaction to batch insertions.

type Model

type Model interface {
	GetFields() []string
	GetValues() []interface{}
	TableName() string
}

Model is an interface for ClickHouse data structures.

Jump to

Keyboard shortcuts

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