Skip to main content

typeddbapi

A lightweight, type-hinted wrapper around Python's DB-API 2.0.

What is typeddbapi?

typeddbapi provides a simple way to connect to databases using URL strings, with full type hints and optional connection pooling. You write raw SQL for your specific database—typeddbapi just passes it through to your driver.

Why typeddbapi?

  • Raw SQL First - No ORM magic, no query translation. You write the SQL you want to execute.
  • Type-Hinted Throughout - Full type annotations for better IDE support and runtime type checking.
  • Driver Agnostic - Works with any DB-API 2.0 compatible driver (psycopg, sqlite3, mysql-connector, asyncpg, aiosqlite, and more).
  • Optional Pooling - Connection pool utilities available when you need them.
  • Async Support - Both synchronous and asynchronous APIs with the same intuitive interface.

[!WARNING] Async support is only for asynchronous drivers (e.g. aiosqlite)

What typeddbapi is NOT

  • Not a cross-database compatibility layer
  • Not an ORM
  • Not a query builder
  • Not a SQL validator or translator

typeddbapi Philosophy

typeddbapi directly gives your raw SQL query to the database driver specified in the URL rather than trying to abstract it away. If someone wants an ORM, they can build one on top.

Connection URLs

typeddbapi uses standard RFC-1738 URLs with dialect and optional driver:

dialect[+driver]://user:pass@host:port/database

Examples:

  • postgresql://localhost/mydb
  • postgresql+asyncpg://localhost/mydb
  • mysql+pymysql://localhost/mydb
  • sqlite:///path/to/file.db

The dialect tells typeddbapi what database you're using, and the optional driver specifies which DB-API 2.0 driver to use. If no driver is specified, the dialect's default driver is used.

Quick Peek

from typeddbapi import connect, ConnectionFactory, Pool

DATABASE_URL = "postgresql+psycopg2://user:pass@localhost/mydb"

# Simple connection
with connect(DATABASE_URL) as conn:
    cursor = conn.cursor()
    cursor.execute("SELECT * FROM users WHERE id = %s", (1,))
    user = cursor.fetchone()
    print(user)

For learning more, look at documentation

Requirements

  • Python 3.7+
  • A DB-API 2.0 compliant driver for your database (install separately)

License

MIT

Metadata

Release files for typeddbapi 1.0.1

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

Source distribution (sdist)

Source distribution for typeddbapi 1.0.1
File Size Uploaded Provenance Actions
typeddbapi-1.0.1.tar.gz 9.8 kB Without provenance Details for typeddbapi-1.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 22.3 kB

Release files / typeddbapi-1.0.1.tar.gz

Download URL typeddbapi-1.0.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a54efd44494f5bfccae841f7b106b559512c2b0f171e7176f982b6679442515d
BLAKE2b-256 checksum
How to use checksums
d54cfa5634c1ba956f0aa80986335f8f3b548be5762f7cff7604702f5cd117af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / typeddbapi-1.0.1-py3-none-any.whl

Download URL typeddbapi-1.0.1-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
571e0c3b7703c48acad2def73bdc54996fe5d53888ed03d6aebe623ae8ab4355
BLAKE2b-256 checksum
How to use checksums
15a1cdcbaf8007c1208efdae0c409e2d2bf3ff54736a66ab1695c3772cac8828
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for typeddbapi 1.0.1

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

1.0.1 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