Skip to main content

Introspect a live database and generate typed, autocomplete-friendly query helpers — no ORM required.

Project description

schema-first-query

PyPI version Python versions License: MIT Coverage Checked with mypy

Introspect a live database and get typed, autocomplete-friendly query helpers — no ORM, no model classes, no boilerplate.


Motivation

Python developers working with relational databases face an uncomfortable tradeoff. Raw SQL with dict rows is fast and flexible, but offers no type safety, no IDE autocomplete, and fragile string-key access that breaks silently when columns are renamed. Full ORMs like SQLAlchemy or Django ORM are typed and ergonomic, but they require maintaining Python model classes that duplicate the database schema — a form of drift-prone redundancy that grows more painful as the schema evolves.

The middle ground — lightweight query builders like SQLAlchemy Core or PyPika — reduces boilerplate but still returns untyped rows, or requires you to write TypedDict definitions by hand. Either way, the schema lives in two places: the database and your Python code.

schema-first-query eliminates that duplication. It connects to your database (or reads your SQL migration files), introspects the schema once, and generates TypedDict or dataclass types on the fly. Your IDE sees fully typed results with autocomplete. Your code stays DRY. The database schema remains the single source of truth — exactly as it should be in a database-first workflow.


Installation

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

schema_first_query-0.1.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

schema_first_query-0.1.0-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file schema_first_query-0.1.0.tar.gz.

File metadata

  • Download URL: schema_first_query-0.1.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.12 Darwin/24.6.0

File hashes

Hashes for schema_first_query-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b6fb1f9d27dcb026c2657b97331e726e26cbc89e46e2ff511471c40be2e5a4c9
MD5 c6305fb0283ac4a12c0f099c84786826
BLAKE2b-256 dc6614f9381dc38e6cb70b83d8ee67d20927bd829752c0e91d8ef46e72d596cc

See more details on using hashes here.

File details

Details for the file schema_first_query-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: schema_first_query-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.12 Darwin/24.6.0

File hashes

Hashes for schema_first_query-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 842a3fdd57e89a8905e4614fbf5d3c5c0e79ecf2683cfcd2a2be8f1aa8f61f64
MD5 ca4e1856450d18e9fb5d0712e5430238
BLAKE2b-256 6bf12846266d9770af2be2d7fecc31e0b359b02ea92cb4641c72e0cfa691ed3c

See more details on using hashes here.

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