Metadata-Version: 2.1
Name: sa-repository
Version: 0.2.1
Summary: Class to provide some general methods to simplify work with SQLAlchemy models
Home-page: https://github.com/Gasper3/sa-repository
Author: Gasper3
Author-email: trzecik65@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: sqlalchemy (>=2.0.2,<3.0.0)
Project-URL: Repository, https://github.com/Gasper3/sa-repository
Description-Content-Type: text/markdown

# SQLAlchemy Repository for models
![tests workflow](https://github.com/Gasper3/sa-repository/actions/workflows/actions.yml/badge.svg)

This project contains simple base repository class for your models.  
All you need to do is:
1. Install this package `python -m pip install sa-repository`
2. Use it in your project
    ```python
    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
```python
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
```python
repository = BaseRepository.get_repository_from_model(db_session, SomeModel)
```

