Skip to main content

SQLModel Query Builder

A serializable object for simple SQLModel queries.

Why this exists

SQLModel is an Object Relation Mapper (ORM) library that provides great abstractions for interacting with relational databases, such as PostgreSQL and SQLite, via Python. SQLModel gives its users the option to write queries using its own "pythonic" functions, which is safer and easier (in my opinion) than writing raw SQL. Here's what an SQLModel looks like:

with Session(engine) as session:
    statement = select(Hero, Team).join(Team).where(Team.name == "Preventers")
    results = session.exec(statement)

In this example, from SQLModel's own documentation, the words Hero and Team are classes that represent tables in the database.

As convenient as it is, this approach to writing queries has a major drawback: there is no built-in to serialize SQLModel queries. The implication is that you cannot easily dump them into a JSON object that can be sent and received in a REST API, which is a major usecase when developing database applications.

Thus, sqlmodel-query-builder exists to close (or at least narrow) this gap by providing a serializable object for SQLModel queries. For now, it only supports simple queries that involve only SELECT, JOIN, and WHERE statements.

License

This work is licensed under the terms of the GPLv3.

Copyright

© 2024 Brazilian Center for Research in Energy and Materials (CNPEM)

Release files for sqlmodel-query-builder 0.1.0

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

Source distribution (sdist)

Source distribution for sqlmodel-query-builder 0.1.0
File Size Uploaded
sqlmodel_query_builder-0.1.0.tar.gz 2.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlmodel-query-builder 0.1.0
File Interpreter ABI Platform
sqlmodel_query_builder-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.0 kB

Release files / sqlmodel_query_builder-0.1.0.tar.gz

Download URL sqlmodel_query_builder-0.1.0.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9390e93f15e62db1222b875240ee32e08186093e566d3c5452bfa69128946f33
BLAKE2b-256 checksum
How to use checksums
abfa217142af1999ff560e61769ea5dfa8cbe82e10251d7e7dc57b25d8298848
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.12.8 Linux/6.12.15-200.fc41.x86_64

Release files / sqlmodel_query_builder-0.1.0-py3-none-any.whl

Download URL sqlmodel_query_builder-0.1.0-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e141a53f4cae6fb474f2f77a5ec9cb1e2af3a78d6493eee9d5220c55e0b3350a
BLAKE2b-256 checksum
How to use checksums
e58f64141eb4a55c5c49bdecdefb23cdf35cac31962d580f8cdde7823287e0d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.12.8 Linux/6.12.15-200.fc41.x86_64

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.2

2 release files

0.0.1

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