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.4.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for sa_repository-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 268ca5ca69c4127f778c4eddf5961ad1b3819ef76c2d8c0183210c9f2b5039c6 |
|
MD5 | 47eff4c6340d3341aaf6422578312413 |
|
BLAKE2b-256 | 59fce1b34c55a45fbe07e64692dba77da09e78b9bf5f5ec8013a97be78d0f439 |