DuckDB Support#

Available for: C/C++, GLib/Ruby, Go, Python

DuckDB provides ADBC support since version 0.8.0.

Note

DuckDB is not part of the Apache Arrow project and is developed separately.

Installation#

See the DuckDB documentation.

Usage#

ADBC support in DuckDB requires the driver manager.

#include "adbc.h"

// Ignoring error handling
struct AdbcDatabase database;
AdbcDatabaseNew(&database, nullptr);
AdbcDatabaseSetOption(&database, "driver", "PATH/TO/libduckdb.so", nullptr);
AdbcDatabaseSetOption(&database, "entrypoint", "duckdb_adbc_init", nullptr);
AdbcDatabaseInit(&database, nullptr);

You must have libduckdb.so on your LD_LIBRARY_PATH, or in the same directory as the executable when you run this. This requires CGO and loads the DuckDB driver.

import (
   "context"

   "github.com/apache/arrow-adbc/go/adbc"
   "github.com/apache/arrow-adbc/go/adbc/drivermgr"
)

func main() {
   var drv drivermgr.Driver
   db, err := drv.NewDatabase(map[string]string{
      "driver": "libduckdb.so",
      "entrypoint": "duckdb_adbc_init",
   })
   if err != nil {
      // handle error
   }

   cnxn, err := db.Open(context.Background())
   if err != nil {
      // handle error
   }
   defer cnxn.Close()
}

Supported Features#

ADBC support in DuckDB is still in progress. See duckdb/duckdb#7141 for details.