Skip to content
DuckDB community extension

adbc

Connects DuckDB to any database that has an Arrow Database Connectivity (ADBC) driver.

01 / SETUP

Install and load

Run these commands in a Haybarn SQL session. The extension is available from the community repository.

Haybarn 2.0.0 Β· SQL
INSTALL adbc FROM community;
LOAD adbc FROM community;

Try it in a temporary SQL session with adbc already loaded. Queries run in this tab; examples using files or services need their own setup.

Using upstream DuckDB? Follow the maintainer’s installation instructions.

02 / QUERY

Usage example

Read from an ADBC database (SQLite) with read_adbc given an ADBC connection profile URI and a SQL query

SQL session and output
-- Install and load the ADBC extension
-- Read from an ADBC database (SQLite) with read_adbc given an ADBC connection profile URI and a SQL query
D SELECT * FROM read_adbc('profile://mydb', 'SELECT * FROM games');
β”Œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  id   β”‚    name    β”‚      inventor       β”‚  year   β”‚ min_age β”‚ min_players β”‚ max_players β”‚ list_price β”‚
β”‚ int64 β”‚  varchar   β”‚       varchar       β”‚ varchar β”‚  int64  β”‚    int64    β”‚    int64    β”‚  varchar   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     1 β”‚ Monopoly   β”‚ Elizabeth Magie     β”‚ 1903    β”‚       8 β”‚           2 β”‚           6 β”‚ 19.99      β”‚
β”‚     2 β”‚ Scrabble   β”‚ Alfred Mosher Butts β”‚ 1938    β”‚       8 β”‚           2 β”‚           4 β”‚ 17.99      β”‚
β”‚     3 β”‚ Clue       β”‚ Anthony E. Pratt    β”‚ 1944    β”‚       8 β”‚           2 β”‚           6 β”‚ 9.99       β”‚
β”‚     4 β”‚ Candy Land β”‚ Eleanor Abbott      β”‚ 1948    β”‚       3 β”‚           2 β”‚           4 β”‚ 7.99       β”‚
β”‚     5 β”‚ Risk       β”‚ Albert Lamorisse    β”‚ 1957    β”‚      10 β”‚           2 β”‚           5 β”‚ 29.99      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
-- Create a table function macro to avoid retyping the connection profile URI each time
D CREATE MACRO read_mydb(query) AS TABLE SELECT * FROM read_adbc('profile://mydb', query);
-- Create a persistent connection to the ADBC database via ATTACH
D ATTACH 'profile://mydb' AS mydb (TYPE adbc);
-- Alternatively, ATTACH with a custom delimiter (i.e., SELECT * FROM [schema].[table] for SQL Server)
D ATTACH 'profile://mydb' AS otherdb (TYPE adbc, DELIMITER '[]');
-- Set the default schema
D USE mydb.main;
-- Display all tables in the attached ADBC database
D SHOW ALL TABLES;
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ database β”‚ schema  β”‚  name   β”‚         column_names          β”‚          column_types          β”‚ temporary β”‚
β”‚ varchar  β”‚ varchar β”‚ varchar β”‚           varchar[]           β”‚           varchar[]            β”‚  boolean  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ mydb     β”‚ main    β”‚ games   β”‚ [id, name, inventor, year,    β”‚ [BIGINT, VARCHAR, VARCHAR,     β”‚ false     β”‚
β”‚          β”‚         β”‚         β”‚  min_age, min_players,        β”‚  VARCHAR, BIGINT, BIGINT,      β”‚           β”‚
β”‚          β”‚         β”‚         β”‚  max_players, list_price]     β”‚  BIGINT, VARCHAR]              β”‚           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
-- Read directly from the attached ADBC table (no predicate pushdown, use read_adbc for that)
D SELECT * FROM games;
β”Œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  id   β”‚    name    β”‚      inventor       β”‚  year   β”‚ min_age β”‚ min_players β”‚ max_players β”‚ list_price β”‚
β”‚ int64 β”‚  varchar   β”‚       varchar       β”‚ varchar β”‚  int64  β”‚    int64    β”‚    int64    β”‚  varchar   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     1 β”‚ Monopoly   β”‚ Elizabeth Magie     β”‚ 1903    β”‚       8 β”‚           2 β”‚           6 β”‚ 19.99      β”‚
β”‚     2 β”‚ Scrabble   β”‚ Alfred Mosher Butts β”‚ 1938    β”‚       8 β”‚           2 β”‚           4 β”‚ 17.99      β”‚
β”‚     3 β”‚ Clue       β”‚ Anthony E. Pratt    β”‚ 1944    β”‚       8 β”‚           2 β”‚           6 β”‚ 9.99       β”‚
β”‚     4 β”‚ Candy Land β”‚ Eleanor Abbott      β”‚ 1948    β”‚       3 β”‚           2 β”‚           4 β”‚ 7.99       β”‚
β”‚     5 β”‚ Risk       β”‚ Albert Lamorisse    β”‚ 1957    β”‚      10 β”‚           2 β”‚           5 β”‚ 29.99      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
-- Insert into the ADBC database
D INSERT INTO games (SELECT 6, 'Battleship', 'Clifford Von Wickler', 1931, 7, 2, 2, 12.99);
D SELECT * FROM games;
β”Œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  id   β”‚    name    β”‚       inventor       β”‚  year   β”‚ min_age β”‚ min_players β”‚ max_players β”‚ list_price β”‚
β”‚ int64 β”‚  varchar   β”‚       varchar        β”‚ varchar β”‚  int64  β”‚    int64    β”‚    int64    β”‚  varchar   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     1 β”‚ Monopoly   β”‚ Elizabeth Magie      β”‚ 1903    β”‚       8 β”‚           2 β”‚           6 β”‚ 19.99      β”‚
β”‚     2 β”‚ Scrabble   β”‚ Alfred Mosher Butts  β”‚ 1938    β”‚       8 β”‚           2 β”‚           4 β”‚ 17.99      β”‚
β”‚     3 β”‚ Clue       β”‚ Anthony E. Pratt     β”‚ 1944    β”‚       8 β”‚           2 β”‚           6 β”‚ 9.99       β”‚
β”‚     4 β”‚ Candy Land β”‚ Eleanor Abbott       β”‚ 1948    β”‚       3 β”‚           2 β”‚           4 β”‚ 7.99       β”‚
β”‚     5 β”‚ Risk       β”‚ Albert Lamorisse     β”‚ 1957    β”‚      10 β”‚           2 β”‚           5 β”‚ 29.99      β”‚
β”‚     6 β”‚ Battleship β”‚ Clifford Von Wickler β”‚ 1931    β”‚       7 β”‚           2 β”‚           2 β”‚ 12.99      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
-- Create a local table in DuckDB of the inventors of each game
D CREATE TABLE memory.inventors AS (SELECT id, inventor FROM games);
-- Create a new table in the attached ADBC database (SQLite) of the inventors
D CREATE TABLE game_inventors(id, inventor) AS (SELECT * FROM memory.inventors);
D SELECT * FROM game_inventors;
β”Œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  id   β”‚       inventor       β”‚
β”‚ int64 β”‚       varchar        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     1 β”‚ Elizabeth Magie      β”‚
β”‚     2 β”‚ Alfred Mosher Butts  β”‚
β”‚     3 β”‚ Anthony E. Pratt     β”‚
β”‚     4 β”‚ Eleanor Abbott       β”‚
β”‚     5 β”‚ Albert Lamorisse     β”‚
β”‚     6 β”‚ Clifford Von Wickler β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
-- Execute arbitrary DDL via adbc_execute
D CALL adbc_execute('profile://mydb', 'DROP TABLE games');
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Success β”‚
β”‚ boolean β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ true    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
-- Clear local metadata cache after remote schema changes
D CALL adbc_clear_cache();

Provided by columnar-tech. Not yet verified on Haybarn 2.0.0.

Sample data & setup

About this extension

Use DuckDB (v1.4.5+ or v1.5.4+) to query Snowflake, Databricks, BigQuery, PostgreSQL, MySQL, or any other system with an ADBC driver. ADBC (Arrow Database Connectivity) is a universal data-access API built on Apache Arrow, an efficient, columnar data format that almost every data system supports natively. By building on Arrow, ADBC enables:

Project overview from the community descriptor.

Documentation and resources

Project and build details
Repository
columnar-tech/duckdb-adbc-client
License
Apache-2.0
Maintainers
SamArch27, columnar-tech
Written in
C++
Build source
b1b13c05d735
Build definition
Community descriptor