diff --git a/cmd/cli/config/config.go b/cmd/cli/config/config.go index 61a7cfb2..84499be9 100644 --- a/cmd/cli/config/config.go +++ b/cmd/cli/config/config.go @@ -22,26 +22,35 @@ func OpenClickHouseConn() (*sql.DB, *Config, error) { if err != nil { return nil, nil, err } - var conns clickhouse.Options + //var conn clickhouse.Options - if cfg.ClickHouseUsername != "" && cfg.ClickHousePassword != "" { - fmt.Println("Using provided username and password") - conns = clickhouse.Options{ - Addr: []string{fmt.Sprintf("%s:%d", cfg.DBAddress, cfg.DbPort)}, - Debug: true, - Auth: clickhouse.Auth{ - Username: cfg.ClickHouseUsername, - Password: cfg.ClickHousePassword, - }, - } - } else { - fmt.Println("Using connection without username and password") - conns = clickhouse.Options{ - Addr: []string{fmt.Sprintf("%s:%d", cfg.DBAddress, cfg.DbPort)}, - } - } + conn := clickhouse.OpenDB(&clickhouse.Options{ + Addr: []string{ + fmt.Sprintf("%s:%d", cfg.DBAddress, cfg.DbPort)}, + Debug: true, + Auth: clickhouse.Auth{ + Username: cfg.ClickHouseUsername, + Password: cfg.ClickHousePassword, + }, + }) + // if cfg.ClickHouseUsername != "" && cfg.ClickHousePassword != "" { + // fmt.Println("Using provided username and password") + // conn = clickhouse.Options{ + // Addr: []string{fmt.Sprintf("%s:%d", cfg.DBAddress, cfg.DbPort)}, + // Debug: true, + // Auth: clickhouse.Auth{ + // Username: cfg.ClickHouseUsername, + // Password: cfg.ClickHousePassword, + // }, + // } + // } else { + // fmt.Println("Using connection without username and password") + // conn = clickhouse.Options{ + // Addr: []string{fmt.Sprintf("%s:%d", conf.DBAddress, conf.DbPort)}, + // } + // } - conn := clickhouse.OpenDB(&conns) + // conn = clickhouse.OpenDB(&conn) if err := conn.Ping(); err != nil { if exception, ok := err.(*clickhouse.Exception); ok { return nil, nil, fmt.Errorf("[%d] %s %s", exception.Code, exception.Message, exception.StackTrace)