Skip to main content

An Apache Arrow ADBC driver for DuckDB's Quack remote protocol.

Project description

adbc-driver-quack

An Apache Arrow ADBC driver for DuckDB's Quack remote protocol.

PyPI PyPI downloads Python versions Go module CI GitHub Repo License: MIT

Returns Apache Arrow RecordBatches directly from a remote DuckDB server speaking Quack. Supports the standard ADBC bulk-ingest path (Statement.BindStreamAPPEND_REQUEST) for fast column-oriented loads.

Distributed as:

  • a Go module — github.com/gizmodata/adbc-driver-quack
  • a pip install adbc-driver-quack wheel for Python (macOS / Linux / Windows × x64 / arm64)

Status: Alpha — v0.1.0-alpha.1 is the first release. The companion gizmodata/quack-jdbc JDBC driver is the same protocol from the JVM and is at v0.1.0-alpha.1 on Maven Central.

Quickstart

1. Start a Quack server (any DuckDB v1.5.3+)

-- in any DuckDB session — Quack is a core extension as of v1.5.3,
-- so no `core_nightly` repository or `-unsigned` flag is needed.
INSTALL quack;
LOAD quack;
CALL quack_serve('quack:localhost:9494', token=>'my-secret-token');

The server stays running until the DuckDB session exits. Press Ctrl-C in the DuckDB REPL to stop it.

Note: quack_serve accepts shorter forms — 'quack:localhost' uses the default port, and a bare quack_serve() with no first arg uses localhost as the host. We keep the explicit localhost:9494 form throughout this README so the client-side URI maps obviously to what the server is bound to.

If localhost ever gives you a connection refused (rare, but it can happen on a system whose /etc/hosts is set up such that the server binds one address family and the client dials the other), use 127.0.0.1 on both sides.

2. Install the driver

Python:

pip install adbc-driver-quack

Go:

go get github.com/gizmodata/adbc-driver-quack@latest

3. Connect and query

import adbc_driver_quack.dbapi as quack
import pyarrow

with quack.connect(
    uri="quack://localhost:9494",
    db_kwargs={"adbc.quack.token": "my-secret-token"},
) as conn, conn.cursor() as cur:
    cur.execute("SELECT 42 AS answer, 'hello duckdb' AS greeting")
    table: pyarrow.Table = cur.fetch_arrow_table()
    print(table)

The result is a real pyarrow.Table — pass it straight to Polars, Pandas, DuckDB-in-process, ibis, or anything else that consumes Arrow:

import polars as pl
df = pl.from_arrow(table)

Alternative: drive adbc_driver_manager directly

If you prefer the adbc-quickstarts idiom — passing the driver to adbc_driver_manager.dbapi.connect rather than going through our wrapper — point at the bundled shared library via _driver_path():

from adbc_driver_manager import dbapi
import adbc_driver_quack

with dbapi.connect(
    driver=adbc_driver_quack._driver_path(),
    entrypoint="QuackDriverInit",
    db_kwargs={
        "uri": "quack://localhost:9494",
        "adbc.quack.token": "my-secret-token",
    },
) as conn, conn.cursor() as cur:
    cur.execute("SELECT 42 AS answer")
    table = cur.fetch_arrow_table()

Both styles work the same on the wire — pick whichever reads better for your codebase.

Streaming large result sets

Cursor.fetch_record_batch() returns a pyarrow.RecordBatchReader that pulls one server-side DataChunk per read_next_batch() call. Memory stays bounded by the server's chunk size (~2k rows) even when the result is millions of rows:

with conn.cursor() as cur:
    cur.execute("SELECT * FROM lineitem")  # arbitrary size
    reader = cur.fetch_record_batch()
    for batch in reader:
        process(batch)  # one ~2k-row Arrow batch at a time

Bulk ingest (Arrow → DuckDB)

import pyarrow as pa
import adbc_driver_quack.dbapi as quack

table = pa.table({"id": [1, 2, 3], "name": ["alice", "bob", "carol"]})
with quack.connect(
    uri="quack://localhost:9494",
    db_kwargs={"adbc.quack.token": "my-secret-token"},
    autocommit=True,  # ADBC connections are autocommit-OFF by default;
                      # opt in here so the ingest persists on close
) as conn, conn.cursor() as cur:
    # create_append: create "customers" from the Arrow schema if it
    # doesn't exist, then append. One APPEND_REQUEST per RecordBatch.
    cur.adbc_ingest(table_name="customers", data=table, mode="create_append")

Heads-up — autocommit is off by default. Per the Python DB-API, quack.connect() opens connections inside a transaction. Without the autocommit=True above (or an explicit conn.commit()), the CREATE + append run in a transaction that is rolled back when the connection closesadbc_ingest still returns the row count it sent, but nothing persists. Prefer explicit transactions? Drop autocommit=True and call conn.commit() after adbc_ingest():

with quack.connect(uri="quack://localhost:9494",
                    db_kwargs={"adbc.quack.token": "my-secret-token"}) as conn, conn.cursor() as cur:
    cur.adbc_ingest(table_name="customers", data=table, mode="create_append")
    conn.commit()  # without this, the ingest is rolled back on close

mode accepts the four standard ADBC ingest modes:

mode behavior
create create the table (errors if it already exists), then append — this is the default when mode is omitted
append append to an existing table (no DDL; errors if missing)
replace CREATE OR REPLACE the table, then append
create_append create the table if it doesn't exist, then append

Table DDL for the create-family modes is generated from the Arrow schema. Pass db_schema_name=... to target a non-default schema.

Transactions (autocommit off)

import adbc_driver_quack.dbapi as quack

with quack.connect(
    uri="quack://localhost:9494",
    db_kwargs={"adbc.quack.token": "..."},
    autocommit=False,
) as conn, conn.cursor() as cur:
    cur.execute("INSERT INTO orders VALUES (1, 'pending')")
    cur.execute("INSERT INTO order_items VALUES (1, 'widget', 2)")
    conn.commit()  # both inserts persist atomically

Connection URL

quack://host[:port]
Option Default Notes
adbc.uri Required. Pass as the uri= kwarg to quack.connect.
adbc.quack.token (none) Authentication token. Server-side token=> argument to quack_serve().
adbc.quack.tls false true → use https:// for the underlying HTTP transport.

The URI is its own kwarg; everything else goes through db_kwargs:

import adbc_driver_quack.dbapi as quack

quack.connect(
    uri="quack://localhost:9494",
    db_kwargs={
        "adbc.quack.token": "my-secret-token",
        "adbc.quack.tls": "false",
    },
)

Why ADBC and not JDBC?

Both drivers speak the same protocol to the same kind of server. Pick the one that fits your runtime:

You're using Reach for
A JVM tool (DBeaver, IntelliJ, Spark, dbt-jdbc, plain java.sql) quack-jdbc
Python (pip install), Go, Rust, R, anything via ADBC C ABI this driver
You want zero-copy Arrow data end-to-end this driver

Repo layout

adbc-driver-quack/
├── go.mod, go.sum
├── internal/
│   ├── codec/       — BinaryReader/Writer for DuckDB BinarySerializer
│   ├── quacktype/   — Logical / physical / extra type system + codec
│   ├── message/     — DataChunk, DecodedVector, MessageCodec, VectorCodec
│   └── transport/   — QuackURI parser + net/http transport (IPv4/IPv6 fallback)
├── driver/quack/    — pure-Go ADBC Driver/Database/Connection/Statement impl
├── pkg/quack/       — cgo c-shared wrapper (produces libadbc_driver_quack.{so,dylib,dll})
├── python/          — Python wheel sources (adbc_driver_quack)
└── .github/         — CI: go test, python tests, cibuildwheel matrix, PyPI publish

The internal/ layer is a clean-room Go port of the matching Java packages in quack-jdbc.

Credits

License

MIT — see LICENSE for full attribution.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

adbc_driver_quack-0.1.0a7-py3-none-win_amd64.whl (8.5 MB view details)

Uploaded Python 3Windows x86-64

adbc_driver_quack-0.1.0a7-py3-none-macosx_15_0_universal2.whl (4.2 MB view details)

Uploaded Python 3macOS 15.0+ universal2 (ARM64, x86-64)

File details

Details for the file adbc_driver_quack-0.1.0a7-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for adbc_driver_quack-0.1.0a7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 029a667d508c9a3c2d95a38d727e3eb2ec49b75c867913ec7371ac7d679a365c
MD5 76b0635a5f7df0b3f280bf4c6b27a14a
BLAKE2b-256 72586892577105d37f2500f69589f4e63326e3be0168ae47b6731f6d43421a67

See more details on using hashes here.

Provenance

The following attestation bundles were made for adbc_driver_quack-0.1.0a7-py3-none-win_amd64.whl:

Publisher: python.yml on gizmodata/adbc-driver-quack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adbc_driver_quack-0.1.0a7-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for adbc_driver_quack-0.1.0a7-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0961039dc26370e66773b4b476e4c0ac2601d4ec1a9d7e56d77ddd1ab6ed4a3d
MD5 b8c539238990a865c9cff85c1e5d20d9
BLAKE2b-256 4edeb1987bc5d5ad7ca5ff86285013cde95d06d366dbf9085d1737bc2e868618

See more details on using hashes here.

Provenance

The following attestation bundles were made for adbc_driver_quack-0.1.0a7-py3-none-manylinux2014_x86_64.whl:

Publisher: python.yml on gizmodata/adbc-driver-quack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adbc_driver_quack-0.1.0a7-py3-none-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for adbc_driver_quack-0.1.0a7-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 deec00b25854bfeb02535592079745edd62fe62c073662aebb745757941afacb
MD5 0ffcc3671230f8cee55898a936378df4
BLAKE2b-256 1dbb308c5b2a9aa0d595b9598408170410abc2ce47d3877dd4461843f41b27a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for adbc_driver_quack-0.1.0a7-py3-none-manylinux2014_aarch64.whl:

Publisher: python.yml on gizmodata/adbc-driver-quack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adbc_driver_quack-0.1.0a7-py3-none-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for adbc_driver_quack-0.1.0a7-py3-none-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 f2b9d098c0e282355f61222eaff02b92902c41b6ea6a106514b07f0256bdfe63
MD5 0de9eea7cd7c9c9834f840e34929f3af
BLAKE2b-256 02b26be4c1dee0a444e80f88c3f725ffee09599758cbd8bb6bd2b660d7778789

See more details on using hashes here.

Provenance

The following attestation bundles were made for adbc_driver_quack-0.1.0a7-py3-none-macosx_15_0_universal2.whl:

Publisher: python.yml on gizmodata/adbc-driver-quack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page