Add your description here
Project description
SQLAlchemy Repository
This repository provides a set of base classes for building SQLAlchemy-based repositories. It includes functionality for performing CRUD operations, querying, and updating database records.
Installation
To use this repository, you need to have SQLAlchemy installed in your environment. You can install it using pip:
pip install sqlalchemy-repository
Usage
To use the repository, you need to create a subclass of
BaseWriteRepository, BaseReadRepository or BaseRepository
for each table you want to manage in your database. Here's an example:
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import sessionmaker, declarative_base, Mapped, mapped_column
from sqlalchemy_repository import BaseRepository
Base = declarative_base()
class MyTable(Base):
id: Mapped[int] = mapped_column(primary_key=True)
title: Mapped[str]
class MyTableRepository(BaseRepository[MyTable, int]):
model = MyTable
# Add any additional custom methods here
To use the repository, you need to provide an instance of AsyncSession when creating an instance of the repository class. You can use the sessionmaker class from SQLAlchemy to create the session: from sqlalchemy_repository.repository import BaseWriteRepository, BaseReadRepository
session = sessionmaker(expire_on_commit=False, autocommit=False, autoflush=False, bind=engine)
repo = MyTableRepository(session())
Features
- full CRUD,
- Django-like queryset in every repository class
- support Django-like Q, F filtering
- annotation and aggregation
- prefetch_related and select_related
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqlalchemy_repository-1.1.0.tar.gz.
File metadata
- Download URL: sqlalchemy_repository-1.1.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78655d2c23480fc7e3a9e4ee51e6e5bb2438ad4191b194df6f22c2967e17e9d2
|
|
| MD5 |
16162c7a7d8bc3a863df18b79c1c697d
|
|
| BLAKE2b-256 |
6b841f577244e30a037d94f189b80e47a9189739d4761f73ac1b4b7c30fdbc18
|
Provenance
The following attestation bundles were made for sqlalchemy_repository-1.1.0.tar.gz:
Publisher:
release.yml on AstralMortem/sqlalchemy-repository
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlalchemy_repository-1.1.0.tar.gz -
Subject digest:
78655d2c23480fc7e3a9e4ee51e6e5bb2438ad4191b194df6f22c2967e17e9d2 - Sigstore transparency entry: 1449154177
- Sigstore integration time:
-
Permalink:
AstralMortem/sqlalchemy-repository@1db6dea165753bb3e12fc998cc539eef471ee918 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/AstralMortem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1db6dea165753bb3e12fc998cc539eef471ee918 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sqlalchemy_repository-1.1.0-py3-none-any.whl.
File metadata
- Download URL: sqlalchemy_repository-1.1.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43b672ce306127295673478039e4e2b7a46deb2e3092cdf0b411aa6f4d730288
|
|
| MD5 |
48f801b526fc55cafde95f8c9e02e7c3
|
|
| BLAKE2b-256 |
a2151fd90d8a0fe8526670e72345e93a5d82076ed71ea88b35136351d725af79
|
Provenance
The following attestation bundles were made for sqlalchemy_repository-1.1.0-py3-none-any.whl:
Publisher:
release.yml on AstralMortem/sqlalchemy-repository
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlalchemy_repository-1.1.0-py3-none-any.whl -
Subject digest:
43b672ce306127295673478039e4e2b7a46deb2e3092cdf0b411aa6f4d730288 - Sigstore transparency entry: 1449154184
- Sigstore integration time:
-
Permalink:
AstralMortem/sqlalchemy-repository@1db6dea165753bb3e12fc998cc539eef471ee918 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/AstralMortem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1db6dea165753bb3e12fc998cc539eef471ee918 -
Trigger Event:
push
-
Statement type: