Giter Site home page Giter Site logo

go-duckdb's Introduction

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.

Installation

go get github.com/marcboeker/go-duckdb

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

git clone https://github.com/cwida/duckdb.git
cd duckdb
make

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 or build/release/src/libduckdb.so (for Linux)
  • build/release/src/libduckdb.dylib (for macOS)
  • build/release/src/libduckdb.dll (for Windows)
  • src/include/duckdb.h

If you don't want to compile DuckDB yourself, you could also use the pre-compiled libraries from their releases page.

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

Usage

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.

go-duckdb's People

Contributors

marcboeker avatar lakemove avatar deka108 avatar pborzenkov avatar mesge avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.