A wrapper around DuckDB to add some convenience.
Project description
pyduckdb
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.
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:
Connection
s implement theexecute*()
functions from the cursor, and return a cursor, as SQLite does.Connection
s andCursor
s implementexecutescript()
as SQLite does.Cursor
s implement the same transactional features as theirConnection
s.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for pyduckdb-0.0.1b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 141209345fe2bc61fe9072f14efccd60a0a748112e601014044e305712e83153 |
|
MD5 | b0d7d82f803b996687bf87c66abbece7 |
|
BLAKE2b-256 | d350e35a00e684dc61339fdcd27856c78174f0349f5be5c80553028b2885b2d0 |