This is a GORM driver for DuckDB, based on the PostgreSQL driver implementation. It uses go-duckdb as the underlying DuckDB driver.
import (
"github.com/kuwa72/duckdb"
"gorm.io/gorm"
)
// Connect to DuckDB
db, err := gorm.Open(duckdb.Open("test.db"), &gorm.Config{})- Supports basic CRUD operations
- Auto-incrementing primary keys using sequences
- Compatible with GORM's standard features
package main
import (
"fmt"
"github.com/kuwa72/duckdb"
"gorm.io/gorm"
)
type Person struct {
ID uint
Name string
Age int
}
func main() {
// Connect to DuckDB
db, err := gorm.Open(duckdb.Open("test.db"), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
// Auto Migrate
db.AutoMigrate(&Person{})
// Create
db.Create(&Person{Name: "John", Age: 30})
// Read
var person Person
db.First(&person)
fmt.Printf("Person: ID=%d, Name=%s, Age=%d\n", person.ID, person.Name, person.Age)
}This driver is currently under development. The following features are implemented:
- Basic connection and configuration
- Auto-incrementing IDs using sequences
- Table creation and migration
- Basic CRUD operations
- Advanced query features
- Complex data types
- Transactions
- Batch operations
- Go 1.20 or higher
- DuckDB
- GORM v1.25.0 or higher
go get github.com/kuwa72/duckdbContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.