forked from baron/baron-sso
users 정보 페이지 구현
This commit is contained in:
@@ -15,6 +15,21 @@ type ClickHouseRepository struct {
|
||||
}
|
||||
|
||||
func NewClickHouseRepository(host string, port int, user, password, db string) (*ClickHouseRepository, error) {
|
||||
// 1. Connect to 'default' database first to ensure target DB exists
|
||||
tmpConn, err := clickhouse.Open(&clickhouse.Options{
|
||||
Addr: []string{fmt.Sprintf("%s:%d", host, port)},
|
||||
Auth: clickhouse.Auth{
|
||||
Database: "default",
|
||||
Username: user,
|
||||
Password: password,
|
||||
},
|
||||
})
|
||||
if err == nil {
|
||||
_ = tmpConn.Exec(context.Background(), fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", db))
|
||||
_ = tmpConn.Close()
|
||||
}
|
||||
|
||||
// 2. Now connect to the target database
|
||||
conn, err := clickhouse.Open(&clickhouse.Options{
|
||||
Addr: []string{fmt.Sprintf("%s:%d", host, port)},
|
||||
Auth: clickhouse.Auth{
|
||||
|
||||
Reference in New Issue
Block a user