Repository pattern for SQLAlchemy models
Project description
SQLAlchemy Repository for models
This project contains simple Repository pattern for SQLAlchemy models.
All you need to do is:
- Install this package
python -m pip install sa-repository
- Use it in your project
from sa_repository import BaseRepository from models import YourSAModel class SomeModelRepository(BaseRepository[YourSAModel]): pass
Base class contains some general methods to simplify your work with sqlalchemy models e.x
var = SomeModelRepository(session).get(YourSAModel.attr == 'some_value')
If you don't want to create new repository classes, you can use get_repository_from_model
method
repository = BaseRepository.get_repository_from_model(db_session, SomeModel)
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
sa_repository-0.5.1.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for sa_repository-0.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d025f1ec0ec9f123414ad18e7c68bfdd3f549ac09dee58fa8a403e8aa4da488f |
|
MD5 | 3fdd3d6a017d152e6c02dbc7e32aad53 |
|
BLAKE2b-256 | bd14563129cf38765b189e46fa4d78d5a0304ff481cf18e06dbf968c64dbc2c0 |