Skip to main content

District 5

Python 3 DB-API and SQLAlchemy dialect to connect to duckdb over http i.e ( Radio-Duck )

(inspiried by my favourite movie Mighty ducks - district5 was the original team name for the mighty ducks )

Requirements

cd PROJECT_DIR
mamba create -n district5 python=3.9
mamba activate district5
mamba install poetry
poetry install

Run Tests

#-without integration test
pytest -m "not integration_test" 
#-with integration test
docker run -d -p 8000:8000 -t jaihind213/radio-duck:latest
pytest

Let's try it out:

#python 3.9^
pip install district5
#start the duckdb server i.e. radio-duck
docker run -p 8000:8000 -t jaihind213/radio-duck:latest
#the duckdb starts up with a sample table whose ddl is: 
#'create table pond(duck_type string, total int)'
echo "we will try to query that"

from sqlalchemy import create_engine, text
from sqlalchemy.dialects import registry

registry.register(
    "radio_duck.district5", "radio_duck.sqlalchemy", "RadioDuckDialect"
)


#run docker instance of radio-duck
#docker run -p 8000:8000 -t jaihind213/radio-duck:latest
engine = create_engine(
    "radio_duck+district5://user:pass@localhost:8000/?api=/v1/sql/&scheme=http"
)
# Establish a database connection
conn = engine.connect()

# Define a SQL query using qmark style or positional style
try:
    query_1 = text("""SELECT duck_type, total FROM pond where total > :total""")
    params = {"total": 0}
    result = conn.execute(query_1, params)
    # Fetch and print the results
    for row in result:
        print(row)

    print("--------------")
    query_2 = "SELECT duck_type, total FROM pond where total > ?"
    result = conn.execute(query_2, (0,))

    for row in result:
        print(row)

except Exception as e:
    print(f"An error occurred: {e}")

finally:
    # Close the database connection
    conn.close()
    engine.dispose()

Metadata

Release files for district5 0.1.18

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

Source distribution (sdist)

Source distribution for district5 0.1.18
File Size Uploaded Provenance Actions
district5-0.1.18.tar.gz 16.9 kB Without provenance Details for district5-0.1.18.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for district5 0.1.18
File Interpreter ABI Platform Actions
district5-0.1.18-py3-none-any.whl Python 3 none any Details for district5-0.1.18-py3-none-any.whl

Total release size: 36.8 kB

Release files / district5-0.1.18.tar.gz

Download URL district5-0.1.18.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d6fe49ac87f54655d481c1d6eb579e989a0c3d7689ac098dce1abb206a3a77a2
BLAKE2b-256 checksum
How to use checksums
616cd9ccd16ac3cb2b3558fa2c5002ac7e49289308897029a636d93400d02f78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.18 Linux/6.2.0-1018-azure

Release files / district5-0.1.18-py3-none-any.whl

Download URL district5-0.1.18-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2a72813d14c395824680e44ea6ef487ecbabf9f017fc0dc7abde24de760be1a
BLAKE2b-256 checksum
How to use checksums
6d13179324e150c82c036af70e3415c3afa8510e8ddb625da98f32954351abe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.9.18 Linux/6.2.0-1018-azure

Security for district5 0.1.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.18 This release

2 release files No provenance

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