Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pyduckdb

Code style: black

Python wrapper for DuckDB to add type hinting and more closely mirror SQLite. This is still a rough work in progress, but should hopefully highlight the utility of the PEP 249 abstract base classes.

This implementation provides Python type hints, context managers, and more distinct cursor types on top of DuckDB. This is not intended to be used in production, but as a test bed for some ideas and to demonstrate the abstract base classes.

Installation

python3 -mpip install pyduckdb

Usage

Uses the standard Python database API.

from pyduckdb import connect

def main():
    with connect(":memory:") as connection:
        with connection.execute("SELECT 1;") as cursor:
            print(next(cursor))

if __name__ == "__main__":
    main()

There is a very naive async implementation available, which essentially involves wrapping every call with asyncio.to_thread:

import asyncio
from pyduckdb.aiopyduckdb import connect

async def main():
    async with connect(":memory:") as connection:
        async with await connection.execute("SELECT 1;") as cursor:
            print(await cursor.fetchone())

if __name__ == "__main__":
    asyncio.run(main())

Differences from the PEP:

  • Connections implement the execute*() functions from the cursor, and return a cursor, as SQLite does.
  • Connections and Cursors implement executescript() as SQLite does.
  • Cursors implement the same transactional features as their Connections.

Metadata

Release files for pyduckdb 0.0.1b3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pyduckdb 0.0.1b3
File Interpreter ABI Platform
pyduckdb-0.0.1b3-py3-none-any.whl Python 3 none any Details

Release files / pyduckdb-0.0.1b3-py3-none-any.whl

Download URL pyduckdb-0.0.1b3-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fc4bbfaac518a4e57ee3f55caa444edc88175cd3ca41ae1e57e010dabe7893c
BLAKE2b-256 checksum
How to use checksums
ef7a472415a9d42599b533402578e65af9ebf53fed3baccf052649af106549a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.0.1b3 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page