Skip to content

Commit

Permalink
fix clickhouse package to enable secure connection to clickhouse cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
negrel committed Jan 23, 2024
1 parent 2b65bfd commit 7bdffdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/clickhouse/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,19 @@ func connectSql(logger log.Logger, cfg config.Clickhouse, maxRetry int) *sql.DB
cfg.User.ExposeSecret(),
cfg.Password.ExposeSecret(),
)
if cfg.TlsEnabled {
connectionString += "&secure=true"
}

db, err = sql.Open("clickhouse", connectionString)
if err != nil {
println(err.Error())
continue
}

err = db.Ping()
if err != nil {
println(err.Error())
continue
}

Expand Down
1 change: 1 addition & 0 deletions internal/clickhouse/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func migrate(logger log.Logger, db *sql.DB) {

driver, err := clickhouse.WithInstance(db, &clickhouse.Config{
MigrationsTable: "migrations",
MigrationsTableEngine: "MergeTree",
MultiStatementEnabled: true,
})
if err != nil {
Expand Down

0 comments on commit 7bdffdb

Please sign in to comment.