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-1.0.0.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for sa_repository-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a4948346b6fc2e66067e79ce30ee893f5348453508e7e991c42d0db35f4c51c |
|
MD5 | b9cf7be1ae2ff3d9e116caff36a62392 |
|
BLAKE2b-256 | 6a3acaf4b5a71a3a8f1ec06ce63f09d4c676402dfead5bfd39312457ce3bcb87 |