Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scottlepp/go-duck
A Golang DuckDB library that doesn't require CGO
https://github.com/scottlepp/go-duck
analytics dataframe dataframes duckdb golang grafana sql
Last synced: 14 days ago
JSON representation
A Golang DuckDB library that doesn't require CGO
- Host: GitHub
- URL: https://github.com/scottlepp/go-duck
- Owner: scottlepp
- License: mit
- Created: 2024-02-20T21:36:55.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-10-21T16:02:44.000Z (16 days ago)
- Last Synced: 2024-10-22T02:55:51.740Z (15 days ago)
- Topics: analytics, dataframe, dataframes, duckdb, golang, grafana, sql
- Language: Go
- Homepage:
- Size: 149 KB
- Stars: 9
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![image](https://github.com/scottlepp/go-duck/assets/6108819/78f3fe95-227a-4b7f-99d5-81d979e5fc2e)
# Go wrapper for [DuckDB CLI](https://duckdb.org/docs/api/cli/overview)
* Doesn't require CGO.
* Requires duckdb cli to be in the path.## In Memory Database
```
db := NewInMemoryDB()commands := []string{
"CREATE TABLE t1 (i INTEGER, j INTEGER);",
"INSERT INTO t1 VALUES (1, 5);",
"SELECT * from t1;",
}
res, err := db.RunCommands(commands)
```
## File based Database
```
db := NewDuckDB("foo")commands := []string{
"CREATE TABLE t1 (i INTEGER, j INTEGER);",
"INSERT INTO t1 VALUES (1, 5);",
}
_, err := db.RunCommands(commands)
res, err := db.Query("SELECT * from t1;")
```## Dataframes
* Allows querying dataframes using SQL, with all the aggregate/window/analytics functions from DuckDB.## Query Dataframes
```
db := NewInMemoryDB()var values = []string{"test"}
frame := data.NewFrame("foo", data.NewField("value", nil, values))
frame.RefID = "foo"
frames := []*data.Frame{frame}res, err := db.QueryFrames("foo", "select * from foo", frames)
```