Skip to content

Instantly share code, notes, and snippets.

@mdibaiee
Created March 27, 2024 16:13
Show Gist options
  • Save mdibaiee/3942fb72ba9d89e5dd2f6e62ed09f8f8 to your computer and use it in GitHub Desktop.
Save mdibaiee/3942fb72ba9d89e5dd2f6e62ed09f8f8 to your computer and use it in GitHub Desktop.
databricks close connection bug
module main
go 1.21.0
require github.com/databricks/databricks-sql-go v1.5.3
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