Lightweight query access-pattern declaration for ORMs
Project description
query-patterns
Declare query access patterns in code and verify matching DB indexes. Supports SQLAlchemy and Django.
What it does
- Collects all @query_pattern declarations
- Extracts ORM indexes
- SQLAlchemy: MetaData
- Django: Model._meta.indexes
- Compares (table, columns) and reports [OK] or [MISSING]
Example output
- [OK] users('email',)
- [MISSING] orders('user_id',)
Install
pip install query-patterns
pip install "query-patterns[sqlalchemy]"
pip install "query-patterns[django]"
Declare a pattern
from query_patterns import query_pattern
class Repo:
@query_pattern(table="users", columns=["email"])
def find(self, email): ...
SQLAlchemy
query-patterns sqlalchemy \
--module myapp.repo \
--metadata myapp.metadata.metadata
# or auto-discover modules
query-patterns sqlalchemy \
--metadata myapp.metadata.metadata
Django
query-patterns django \
--settings config.settings \
--module myapp.repo
# or auto-discover modules
query-patterns django \
--settings config.settings
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
query_patterns-0.1.2.tar.gz
(8.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file query_patterns-0.1.2.tar.gz.
File metadata
- Download URL: query_patterns-0.1.2.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84537793fbf15d467a8eb15ac18469e98698e408c5b2af8398215ea7118c9f94
|
|
| MD5 |
d2a67f8673285b2289bfe486eb63db70
|
|
| BLAKE2b-256 |
c63cd77cc5ce5c31d16e8fb4e4f1563f0290478bfac56334710134bf615cb6af
|
File details
Details for the file query_patterns-0.1.2-py3-none-any.whl.
File metadata
- Download URL: query_patterns-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08682154633db8800980742d796d1a9a9764011c76bfc5f8105cfb413849e5da
|
|
| MD5 |
e5c4175b508b7acf1da90fb51b8db9dc
|
|
| BLAKE2b-256 |
309b212b44b3b5ae7d97c5dc46e70f5762a1722338b30d2a21c32524232c2a79
|