Skip to content

Commit

Permalink
fix: close mysql connection after create database
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Kramm <[email protected]>
  • Loading branch information
FabianKramm committed Nov 12, 2024
1 parent 810f408 commit 4a698dd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/drivers/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func createDBIfNotExist(dataSourceName string) error {
if err != nil {
return err
}
defer db.Close()

var exists bool
err = db.QueryRow("SELECT 1 FROM information_schema.SCHEMATA WHERE schema_name = ?", dbName).Scan(&exists)
Expand All @@ -195,6 +196,7 @@ func createDBIfNotExist(dataSourceName string) error {
if err != nil {
return err
}
defer db.Close()
if _, err = db.Exec(stmt); err != nil {
return err
}
Expand Down

0 comments on commit 4a698dd

Please sign in to comment.