Skip to main content

relq

relq is a type-safe SQL query builder for Python 3.15+. It targets SQLite and PostgreSQL only, and makes invalid or dangerous query construction hard to express before runtime: immutable builders, structured expressions, parameterized values only.

uv add "relq[sqlite]"
# or
uv add "relq[postgres]"
from relq import Column, Table, column, select


class Users(Table):
    id: Column[int] = column(int, primary_key=True)
    email: Column[str] = column(str)
    active: Column[bool] = column(bool)


users = Users("users")
query = select(users.id, users.email).from_(users).where(users.active.is_true())

Features

  • Typed SELECT/INSERT/UPDATE/DELETE, aliases and self-joins, predicates, scalar/correlated subqueries, declared derived relations and CTEs, portable set operations.
  • Conflict-aware upserts, aggregates, portable GROUP BY validation, and window functions on both engines.
  • SQL truth kept honest: Predicate (bool) vs NullablePredicate (bool | None), matching SQL's UNKNOWN.
  • Raw driver results and typed model results are distinct static states, with no implicit decoding.
  • relq-codegen generates committed schema modules from an existing database.

There is intentionally no raw SQL, generic function builder, custom dialect, or implicit result decoding. See Design boundaries for the complete list and the reasoning.

Documentation

The manual covers installation, the full query and DML surface, execution, and code generation. Start at Get started.

Contributing

See contributing.md.

Metadata

Release files for relq 0.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 relq 0.0.1
File Size Uploaded
relq-0.0.1.tar.gz 27.5 kB Details

Built distribution (wheel)

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

Total release size: 65.0 kB

Release files / relq-0.0.1.tar.gz

Download URL relq-0.0.1.tar.gz
Size 27.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ede10a43b30452789ea07d78bb0e16591494e4c19b0d500b2357653087bb54ad
BLAKE2b-256 checksum
How to use checksums
88766b7f6dfdeee493357b37073d00817690b6809ddcac24ba3dc7659c09f12f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.

Transparency log

Release files / relq-0.0.1-py3-none-any.whl

Download URL relq-0.0.1-py3-none-any.whl
Size 37.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea69e544e61b873aa140cc40ab272174d088a7d35f553d12a7aedaa07a805890
BLAKE2b-256 checksum
How to use checksums
34216002573f7beefbcc4657dd516421ec523d4f80f3982530c7a743dc632621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.0

2 release files

This release

0.0.1 This release

2 release files

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