Files
Enterprise-Knowledge-Base/cmd/download/duckdb/duckdb.go
T
wizardchen 2a5cf57589 fix: improve Makefile and duckdb.go for better environment handling
- 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.
2026-03-02 21:21:49 +08:00

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()
}