Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithunikzz committed Oct 30, 2023
1 parent 8e37196 commit dc0db09
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions cmd/cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit dc0db09

Please sign in to comment.