Skip to content

Commit dc0db09

Browse files
committed
fix
1 parent 8e37196 commit dc0db09

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

cmd/cli/config/config.go

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

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-
}
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+
// }
4352

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

0 commit comments

Comments
 (0)