func NewDB(cnf config.ClickhouseConfig, log *zap.SugaredLogger) (*DB, error) {
	db, err := sql.Open("clickhouse", "tcp://"+cnf.Addr+"?write_timeout=60")
	if err != nil {
		return nil, err
	}
	err = db.Ping()
	if err != nil {
		exception, ok := err.(*clickhouse.Exception)
		if ok {
			err = fmt.Errorf("[%d] %s \n%s", exception.Code, exception.Message, exception.StackTrace)
		}
		return nil, err
	}
	sql, ok := cnf.PartitionQueries[cnf.ShardType]
	if !ok {
		return nil, errors.New("Unsupported shard type: " + cnf.ShardType)
	}
	dbObj := &DB{
		logger:       log,
		DB:           db,
		partitionSQL: sql,
	}
	log.Info("Started DB")
	return dbObj, nil
}
GetDB returns new DB object
package clickhouse
import (
	"database/sql"
	"errors"
	"fmt"
	"github.com/kak-tus/loghouse-acceptor/config"
	"github.com/kshvakov/clickhouse"
	"go.uber.org/zap"
)