2a5cf57589
- Updated the Makefile to export the EDITION variable for the lite build process, ensuring proper environment setup. - Added a defer statement in duckdb.go to ensure the SQL database connection is closed after use, improving resource management. These changes enhance the build process and resource handling in the application.
35 lines
623 B
Go
35 lines
623 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
_ "github.com/duckdb/duckdb-go/v2"
|
|
)
|
|
|
|
func downloadSpatial() {
|
|
ctx := context.Background()
|
|
|
|
sqlDB, err := sql.Open("duckdb", ":memory:")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer sqlDB.Close()
|
|
|
|
// Try to install spatial extension (may already be installed or network unavailable)
|
|
installSQL := "INSTALL spatial;"
|
|
if _, err := sqlDB.ExecContext(ctx, installSQL); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
// Try to load spatial extension
|
|
loadSQL := "LOAD spatial;"
|
|
if _, err := sqlDB.ExecContext(ctx, loadSQL); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
downloadSpatial()
|
|
}
|