Skip to content
go-duckdb provides a database/sql driver for the DuckDB database engine.
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Use C-API for prepared statements May 31, 2019
.gitignore Cleanup May 16, 2019
LICENSE Initial import May 15, 2019 Initial import May 15, 2019
connection.go Use duckdb_nparams to get param count Jul 1, 2019
duckdb.go Use C-API for prepared statements May 31, 2019
go.mod Initial import May 15, 2019
result.go Fix memory leak May 17, 2019
rows.go Use C-API for prepared statements May 31, 2019
statement.go Use duckdb_nparams to get param count Jul 1, 2019
transaction.go Implement transactions May 16, 2019

Go SQL driver for DuckDB

This is a WIP version of the DuckDB Go driver.

The DuckDB driver conforms to the built-in database/sql interface.


go get

go-duckdb uses CGO to make calls to the linked DuckDB database. Therefor you need to have a compiled version of DuckDB availabe.

Please locate the following files in your DuckDB directory, as we need them to use the go-duckdb driver:

  • build/release/src/libduckdb{_static}.a (for Linux)
  • build/release/src/libduckdb.dylib (for macOS)
  • build/release/src/libduckdb.dll (for Windows)
  • src/include/duckdb.h

To run the example or execute the tests please specify the following CGO_LDFLAGS, CGO_CFLAGS and the DYLD_LIBRARY_PATH (if you are on macOS) env variables.

CGO_LDFLAGS="-L/path/to/libduckdb_static.a" CGO_CFLAGS="-I/path/to/duckdb.h" DYLD_LIBRARY_PATH="/path/to/libduckdb.dylib" go run examples/simple.go

For example on macOS:

CGO_LDFLAGS="-L/path/to/duckdb/build/release/src" CGO_CFLAGS="-I/path/to/duckdb/src/include" DYLD_LIBRARY_PATH="/path/to/duckdb/build/release/src" go run examples/simple.go


go-duckdb hooks into the database/sql interface provided by the Go stdlib. To open a connection, simply specify the driver type as duckdb:

db, err := sql.Open("duckdb", "")

This creates an in-memory instance of DuckDB. If you would like to store the data on the filesystem, you need to specify the path where to store the data:

db, err := sql.Open("duckdb", "/path/to/foo.db")

Please refer to the database/sql GoDoc for further usage instructions.

You can’t perform that action at this time.