Skip to main content

Repository pattern for SQLAlchemy models

Project description

SQLAlchemy Repository for models

tests workflow

This project contains simple Repository pattern for SQLAlchemy models.
All you need to do is:

  1. Install this package python -m pip install sa-repository
  2. 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


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.0.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

sa_repository-0.5.0-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page