Skip to content

Commit db2f207

Browse files
committed
fix
1 parent dc0db09 commit db2f207

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

cmd/cli/config/config.go

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,26 @@ func OpenClickHouseConn() (*sql.DB, *Config, error) {
2222
if err != nil {
2323
return nil, nil, err
2424
}
25-
//var conn clickhouse.Options
25+
var conns clickhouse.Options
2626

27-
conn := clickhouse.OpenDB(&clickhouse.Options{
28-
Addr: []string{
29-
fmt.Sprintf("%s:%d", cfg.DBAddress, cfg.DbPort)},
30-
Debug: true,
31-
Auth: clickhouse.Auth{
32-
Username: cfg.ClickHouseUsername,
33-
Password: cfg.ClickHousePassword,
34-
},
35-
})
36-
// if cfg.ClickHouseUsername != "" && cfg.ClickHousePassword != "" {
37-
// fmt.Println("Using provided username and password")
38-
// conn = clickhouse.Options{
39-
// Addr: []string{fmt.Sprintf("%s:%d", cfg.DBAddress, cfg.DbPort)},
40-
// Debug: true,
41-
// Auth: clickhouse.Auth{
42-
// Username: cfg.ClickHouseUsername,
43-
// Password: cfg.ClickHousePassword,
44-
// },
45-
// }
46-
// } else {
47-
// fmt.Println("Using connection without username and password")
48-
// conn = clickhouse.Options{
49-
// Addr: []string{fmt.Sprintf("%s:%d", conf.DBAddress, conf.DbPort)},
50-
// }
51-
// }
27+
if cfg.ClickHouseUsername != "" && cfg.ClickHousePassword != "" {
28+
fmt.Println("Using provided username and password")
29+
conns = clickhouse.Options{
30+
Addr: []string{fmt.Sprintf("%s:%d", cfg.DBAddress, cfg.DbPort)},
31+
Debug: true,
32+
Auth: clickhouse.Auth{
33+
Username: cfg.ClickHouseUsername,
34+
Password: cfg.ClickHousePassword,
35+
},
36+
}
37+
} else {
38+
fmt.Println("Using connection without username and password")
39+
conns = clickhouse.Options{
40+
Addr: []string{fmt.Sprintf("%s:%d", cfg.DBAddress, cfg.DbPort)},
41+
}
42+
}
5243

53-
// conn = clickhouse.OpenDB(&conn)
44+
conn := clickhouse.OpenDB(&conns)
5445
if err := conn.Ping(); err != nil {
5546
if exception, ok := err.(*clickhouse.Exception); ok {
5647
return nil, nil, fmt.Errorf("[%d] %s %s", exception.Code, exception.Message, exception.StackTrace)

0 commit comments

Comments
 (0)