Created
March 27, 2024 16:13
-
-
Save mdibaiee/3942fb72ba9d89e5dd2f6e62ed09f8f8 to your computer and use it in GitHub Desktop.
databricks close connection bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module main | |
go 1.21.0 | |
require github.com/databricks/databricks-sql-go v1.5.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"database/sql" | |
"fmt" | |
"os" | |
"time" | |
_ "github.com/databricks/databricks-sql-go" | |
) | |
func main() { | |
var uri = os.Getenv("DATABRICKS_URI") | |
db, err := sql.Open("databricks", uri) | |
if err != nil { | |
panic(fmt.Errorf("sql.Open: %w", err)) | |
} | |
err = db.PingContext(context.Background()) | |
if err != nil { | |
panic(fmt.Errorf("sql.Open: %w", err)) | |
} | |
db.Close() | |
fmt.Println("closed database connection at: %s", time.Now()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment