Skip to main content

Python SDK for DuckGresQL — DuckDB-compatible API for remote databases

Reason this release was yanked:

Migrate to 1.4.4.2 or above

Project description

DuckGresQL Python SDK

Python client for DuckGresQL — a DuckDB-compatible API for remote databases. Uses Arrow Flight SQL for fast query execution and a REST API for async job management.

Installation

Requires Python 3.11+

pip install duckgresql

With optional extras:

pip install duckgresql[pandas]   # adds fetchdf() support
pip install duckgresql[all]      # pandas + numpy

Quick Start

Synchronous

import duckgresql

conn = duckgresql.connect(
    token="dkgql_your_api_token",
    database="my_database",
)

# Execute a query
result = conn.execute("SELECT * FROM users LIMIT 10")
print(result.fetchall())

# Get a pandas DataFrame
df = conn.execute("SELECT * FROM sales").fetchdf()

# DML
result = conn.execute("INSERT INTO users (name) VALUES ('Alice')")
print(result.rowcount)  # affected rows

conn.close()

Async

import asyncio
import duckgresql

async def main():
    conn = await duckgresql.connect_async(
        token="dkgql_your_api_token",
        database="my_database",
    )

    result = await conn.execute("SELECT * FROM users")
    print(result.fetchall())

    await conn.close()

asyncio.run(main())

Context Manager

with duckgresql.connect(token="...", database="...") as conn:
    result = conn.execute("SELECT 1")
    print(result.fetchone())

Async Jobs (Long-Running Queries)

conn = duckgresql.connect(token="...", database="...")

job = conn.execute_async("SELECT * FROM very_large_table")
print(f"Job submitted: {job.job_id}")

# Poll until done (with exponential backoff)
result = job.result(timeout=600)
print(result.fetchall())

Connection Parameters

Parameter Default Description
token required API token (dkgql_…)
database required Database name or UUID

Result Methods

Method Returns Description
fetchone() tuple | None Next row
fetchmany(size) list[tuple] Up to size rows
fetchall() list[tuple] All remaining rows
fetchdf() DataFrame Pandas DataFrame (requires pandas)
fetchnumpy() dict[str, ndarray] NumPy arrays (requires numpy)
fetch_arrow_table() pyarrow.Table Zero-copy Arrow table

Result Properties

Property Type Description
description list | None DB-API 2.0 column metadata
rowcount int Row count or affected rows
columns list[str] Column names

Architecture

  • Arrow Flight SQL (gRPC) — Primary transport for execute(). Fast, columnar, zero-copy.
  • REST API — Used only for execute_async() (job submission/polling), since Flight SQL has no native job queue pattern.

Both transports authenticate via the same API token. Flight SQL uses BasicAuth handshake; REST uses the /connect endpoint to exchange the token for a session token.


Developing the SDK? See CONTRIBUTING.md for setup, testing, building, and publishing.

Project details


Download files

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

Source Distribution

duckgresql-1.4.4.1.tar.gz (61.8 kB view details)

Uploaded Source

Built Distribution

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

duckgresql-1.4.4.1-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file duckgresql-1.4.4.1.tar.gz.

File metadata

  • Download URL: duckgresql-1.4.4.1.tar.gz
  • Upload date:
  • Size: 61.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for duckgresql-1.4.4.1.tar.gz
Algorithm Hash digest
SHA256 8f95b5c64f85c1049bf6faabbda869160e094788c0694e8baf630b0084cf8e62
MD5 447a7741e812d3e4b32a9ed7718c22b8
BLAKE2b-256 30da580e61cd1f81e7846b332dd3e38c8e480405874017d9977add56327eac60

See more details on using hashes here.

Provenance

The following attestation bundles were made for duckgresql-1.4.4.1.tar.gz:

Publisher: release.yml on Duckgresql/python-sdk

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

File details

Details for the file duckgresql-1.4.4.1-py3-none-any.whl.

File metadata

  • Download URL: duckgresql-1.4.4.1-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for duckgresql-1.4.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ddb0c8526ee4667da17a28b4fea45825914cf44cf2b469deb22be31a06b08cd7
MD5 286b79ffcf3b4bd6e94f367e5fd8c75e
BLAKE2b-256 da23d34d2b54a422f2677cf8a6b7e916df4cd4fefc369e07f7e73b3a22e4a1f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for duckgresql-1.4.4.1-py3-none-any.whl:

Publisher: release.yml on Duckgresql/python-sdk

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