No project description provided
Project description
SQLMako
SQLMako is a Python library that supercharges your SQLModel experience, infusing it with the intuitive queryset interface inspired by Django.
Key Features:
- Django-Inspired QuerySets: Unleash the power of familiar operations like
filter
,exclude
,order_by
,get
,all
, and more on your SQLModel models. - Enhanced Readability: Craft SQL queries in a clean, expressive, and chainable style.
- Seamless SQLModel Integration: Works seamlessly with your existing SQLModel models, requiring no major refactoring.
- Extensible: Customize and extend the queryset functionality to fit your specific needs.
Disclaimer: SQLMako is currently in active development. We encourage your feedback and contributions as we work towards a stable release.
Installation
pip install sqlmako
Usage Examples
Basic Querying
from sqlmako import SQLMako, Field, Session, create_engine
from typing import Optional
class Hero(SQLMako, table=True):
id: Optional[int] = Field(default=None, primary_key=True, index=True)
name: str
secret_name: str
age: Optional[int] = Field(default=None)
def main():
engine = create_engine("postgresql+psycopg2://user:password@host/database")
with Session(engine) as session:
SQLMako.metadata.create_all(engine) # Create the table (only needed once)
# Create instances
hero_1 = Hero(name="Deadpond", secret_name="Dive Wilson")
session.add(hero_1)
session.commit()
# Filter and fetch
hero = Hero.objects(session).get(name="Deadpond")
print(hero) # Output: Hero(id=1, name='Deadpond', secret_name='Dive Wilson', age=None)
if __name__ == "__main__":
main()
Advanced Queries:
# Filtering (Multiple Conditions)
heroes = Hero.objects(session).filter(age__gt=30, name__startswith="S")
# Ordering
heroes = Hero.objects(session).order_by(age="desc")
# ... and more! (Explore the full queryset API)
Documentation
Coming Soon: Detailed documentation with comprehensive examples and API references.
Contributing
We welcome contributions! Please check out the Contributing Guidelines for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Built Distribution
File details
Details for the file sqlmako-0.0.1.tar.gz
.
File metadata
- Download URL: sqlmako-0.0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c55f9a3db5b2672449510a37e63ca9b720672087cfc30a9c3e754bec61c07524 |
|
MD5 | 76804fa285060dde48d1d4db19d4d3d1 |
|
BLAKE2b-256 | cb5aaa4958c2a75fd76d6f7c9a1856a49b8b91da535b43725ed98ba7b7de98d6 |
File details
Details for the file sqlmako-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: sqlmako-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc9fd71e2ba36c855e3284ed364807f7cc00b553e7c394d6f1d3d87814176d36 |
|
MD5 | df37491894f150334c5fdae52b22d7de |
|
BLAKE2b-256 | 68f720ddf9aa8cd43b9cd96d4ca5954da73e8bf5630398a615b46fa454ee3313 |