Minimal Cython-based DuckDB Bindings
Project description
bareduckdb
Simplified, Dynamically Linked DuckDB Python Bindings — Fast, simple, and free-threaded.
Overview
bareduckdb provides extensible and easy to build Python bindings to DuckDB using Cython.
- Simple ~4k lines of code - easy to extend or customize
- Arrow-first data conversion supporting Polars, PyArrow, and Pandas
- Support for latest Python features Free threading, subinterpreters, and asyncio
- Dynamically linked to DuckDB's official library
Installation
From PyPI
pip install bareduckdb
From Source
git clone --recurse-submodules https://github.com/paultiq/bareduckdb.git
cd bareduckdb
uv sync -v # or: pip install -e .
Basic Usage
import bareduckdb
# Connect to in-memory database
conn = bareduckdb.connect()
# Execute query and get Arrow Table
result = conn.execute("SELECT 42 as answer").arrow_table()
print(result)
# Convert to Polars/Pandas/PyArrow
df_polars = conn.execute("SELECT * FROM range(100)").pl()
df_pandas = conn.execute("SELECT * FROM range(100)").df()
Async API
import asyncio
from bareduckdb.aio import connect_async
async def run_query():
async with await connect_async() as conn:
result = await conn.execute("SELECT * FROM generate_series(1, 1000)")
return result
result = asyncio.run(run_query())
Polars Integration
import bareduckdb
import polars as pl
conn = bareduckdb.connect()
# Polars -> DuckDB (Arrow Capsule protocol)
df = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
conn.register("my_table", df)
# DuckDB -> Polars (direct conversion)
result = conn.execute("SELECT * FROM my_table", output_type="polars")
Architecture
Design Principles
- Keep it in Python — Business logic lives in Python, not Cython/C++
- No GIL interaction from DuckDB threads — All Python operations happen before/after query execution
- Semantic Versioning — Strict stability guarantees
- Arrow-first — All data types map through Arrow's type system
Why Arrow-First?
By forcing all conversions through Arrow, bareduckdb achieves:
- Consistent type mappings across Polars/Pandas/PyArrow
- Reduced code complexity (no per-library conversion paths)
- Better memory efficiency (zero-copy where possible)
- Future-proof (Arrow is the lingua franca for columnar data)
Thread Safety & Free-Threading
Free-threading support (Python 3.13+):
- No global locks in critical paths
- DuckDB threads never acquire the GIL
- Safe concurrent query execution in
--disable-gilmode - Atomic operations for Arrow stream coordination
APIs
bareduckdb provides multiple API layers for different use cases:
1. Core API (bareduckdb.core)
Minimal, no-frills interface for maximum performance.
from bareduckdb.core import Connection
conn = Connection()
result = conn.execute("SELECT 1")
2. Async API (bareduckdb.aio)
Non-blocking operations with async/await.
from bareduckdb.aio import connect_async
conn = await connect_async()
result = await conn.execute("SELECT 1")
3. Compatibility API (bareduckdb.compat)
Familiar interface similar to duckdb-python (with intentional differences).
import bareduckdb
conn = bareduckdb.connect()
result = conn.sql("SELECT 1") # Eager execution
4. DBAPI 2.0 (bareduckdb.dbapi)
Standard Python database interface for compatibility with tools like SQLAlchemy.
from bareduckdb.dbapi import connect
conn = connect()
cursor = conn.cursor()
cursor.execute("SELECT 1")
Key Differences
Not (Yet?) Supported
- No lazy
DuckDBPyRelationobjects - No Python UDFs
- No automatic DataFrame registration (use
.register()explicitly) - Added Inline Registration:
.execute("....query...", data={"name": df}) - No fsspec integration
Arrow Enhancements
<TBD: Document>
- Capsule vs Table registration
- Deadlock detection
- Cardinality & TopN
- C++ implementation of Arrow Pushdown
Type Mappings
All types convert through Arrow:
- UUIDs: Returned as strings (Arrow doesn't have native UUID type)
- Decimals: Arrow
Decimal128/Decimal256 - Timestamps: Arrow
Timestampwith timezone preservation - Nested Types: Struct/List/Map fully supported
Development
Building from Source
# Clone with submodules (sparse checkout is automatic)
git clone --recurse-submodules https://github.com/paultiq/bareduckdb.git
cd bareduckdb
# Install development dependencies
uv sync
# Build in development mode
pip install -e .
* Note 1: DuckDB submodule version must match the library version. * Note 2: PyArrow version must match the runtime version for Table registration / Pushdown
Disclaimer
For official Python bindings, see: https://github.com/duckdb/duckdb-python
License
bareduckdb is licensed under the MIT License. See LICENSE for details.
All original copyrights are retained by their respective owners, including DuckDB and DuckDB-Python
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bareduckdb-0.3.142-cp314-cp314t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bareduckdb-0.3.142-cp314-cp314t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 31.3 MB
- Tags: CPython 3.14t, manylinux: glibc 2.26+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4d9cfa8cf8d998aacdcd23197a0200eaea999e0f0c567e7f306ef6a22b4adfd
|
|
| MD5 |
a1602301d6d132ea14193ccd5a32eb14
|
|
| BLAKE2b-256 |
5f9c4667230dcbbd096b3f09d9d8897a19661f28e30742d06f72aec00227f66e
|
Provenance
The following attestation bundles were made for bareduckdb-0.3.142-cp314-cp314t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build_wheels.yml on iqmo-org/bareduckdb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bareduckdb-0.3.142-cp314-cp314t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
d4d9cfa8cf8d998aacdcd23197a0200eaea999e0f0c567e7f306ef6a22b4adfd - Sigstore transparency entry: 738083254
- Sigstore integration time:
-
Permalink:
iqmo-org/bareduckdb@0b8f4bb37a6b5446786f9c11b1aabf8f2f356688 -
Branch / Tag:
refs/tags/v0.3.142 - Owner: https://github.com/iqmo-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@0b8f4bb37a6b5446786f9c11b1aabf8f2f356688 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bareduckdb-0.3.142-cp314-cp314t-macosx_11_0_arm64.whl.
File metadata
- Download URL: bareduckdb-0.3.142-cp314-cp314t-macosx_11_0_arm64.whl
- Upload date:
- Size: 34.5 MB
- Tags: CPython 3.14t, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2463100196b90d31941e2db5d5939fb57ce29ec0849bc8373c77b20f238ee53e
|
|
| MD5 |
43d68d9ab91551f1dddeaf96e8aa9e0f
|
|
| BLAKE2b-256 |
2e9da38bf2c993fed627e011c67bf8c503b72b91e0f5c0ce6280eb3ca23f8926
|
Provenance
The following attestation bundles were made for bareduckdb-0.3.142-cp314-cp314t-macosx_11_0_arm64.whl:
Publisher:
build_wheels.yml on iqmo-org/bareduckdb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bareduckdb-0.3.142-cp314-cp314t-macosx_11_0_arm64.whl -
Subject digest:
2463100196b90d31941e2db5d5939fb57ce29ec0849bc8373c77b20f238ee53e - Sigstore transparency entry: 738083261
- Sigstore integration time:
-
Permalink:
iqmo-org/bareduckdb@0b8f4bb37a6b5446786f9c11b1aabf8f2f356688 -
Branch / Tag:
refs/tags/v0.3.142 - Owner: https://github.com/iqmo-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@0b8f4bb37a6b5446786f9c11b1aabf8f2f356688 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bareduckdb-0.3.142-cp312-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bareduckdb-0.3.142-cp312-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 31.2 MB
- Tags: CPython 3.12+, manylinux: glibc 2.26+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83b9666445aa95acb3c93cdec04b862d3cdf65cbdf4dedd4e4f3b1f44f8237ef
|
|
| MD5 |
89555ea96306ecbbaac95156dc935eb9
|
|
| BLAKE2b-256 |
ec73605042861787ddb82d1421d8d457d0b111a63b9e4f50a155073a0b6eb2dd
|
Provenance
The following attestation bundles were made for bareduckdb-0.3.142-cp312-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build_wheels.yml on iqmo-org/bareduckdb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bareduckdb-0.3.142-cp312-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
83b9666445aa95acb3c93cdec04b862d3cdf65cbdf4dedd4e4f3b1f44f8237ef - Sigstore transparency entry: 738083256
- Sigstore integration time:
-
Permalink:
iqmo-org/bareduckdb@0b8f4bb37a6b5446786f9c11b1aabf8f2f356688 -
Branch / Tag:
refs/tags/v0.3.142 - Owner: https://github.com/iqmo-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@0b8f4bb37a6b5446786f9c11b1aabf8f2f356688 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bareduckdb-0.3.142-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: bareduckdb-0.3.142-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 34.4 MB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd6f74e7e7b34fc753bc1c46150a4951a593a8193a978b6fb20014a0d6572f68
|
|
| MD5 |
166ff1e1caac424650f26f58abe2e55f
|
|
| BLAKE2b-256 |
ed1cc215d8cad8e62570195c21bbcd5f491c60e6d52303f032928e6a30d72365
|
Provenance
The following attestation bundles were made for bareduckdb-0.3.142-cp312-abi3-macosx_11_0_arm64.whl:
Publisher:
build_wheels.yml on iqmo-org/bareduckdb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bareduckdb-0.3.142-cp312-abi3-macosx_11_0_arm64.whl -
Subject digest:
dd6f74e7e7b34fc753bc1c46150a4951a593a8193a978b6fb20014a0d6572f68 - Sigstore transparency entry: 738083257
- Sigstore integration time:
-
Permalink:
iqmo-org/bareduckdb@0b8f4bb37a6b5446786f9c11b1aabf8f2f356688 -
Branch / Tag:
refs/tags/v0.3.142 - Owner: https://github.com/iqmo-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheels.yml@0b8f4bb37a6b5446786f9c11b1aabf8f2f356688 -
Trigger Event:
push
-
Statement type: