Repository Patterns for Python
Generic database implemetation for SQL, MongoDB and in-memory lists
Repository pattern is a technique to abstract the data access from the domain/business logic. In other words, it decouples the database access from the application code. The aim is that the code runs the same regardless if the data is stored to an SQL database, NoSQL database, file or even as an in-memory list.
Read more about the repository patterns in the official documentation.
Why?
Repository pattern has several benefits over embedding the database access to the application:
- Faster prototyping and development
- Easier to migrate the database
- More readable code, Pythonic
- Unit testing and testing in general is safer and easier
Features
Main features:
- Support for Pydantic models for data validation
- Identical way to create, read, update and delete (CRUD)
- Pythonic and simple syntax
- Support for more complex queries (greater than, not equal, less than etc.)
Supported repositories:
- SQL
- MongoDB
- In-memory (Python list)
- JSON files
- CSV file
Examples
First, we create a simple repo:
from redbird.repos import MemoryRepo
repo = MemoryRepo()
Note: the following examples work on any repository, not just in-memory repository.
Adding/creating items:
repo.add({"name": "Anna", "nationality": "British"})
Reading items:
repo.filter_by(name="Anna").all()
Updating items:
repo.filter_by(name="Anna").update(nationality="Finnish")
Deleting items:
repo.filter_by(name="Anna").delete()
See more from the official documentation.
Author
- Mikael Koli - Miksus - koli.mikael@gmail.com
Metadata
Release files for redbird 0.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| redbird-0.7.1.tar.gz | 154.9 kB | Without provenance | Details for redbird-0.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| redbird-0.7.1-py3-none-any.whl | Python 3 | none | any | Details for redbird-0.7.1-py3-none-any.whl |
Total release size: 215.0 kB
Release files / redbird-0.7.1.tar.gz
| Download URL | redbird-0.7.1.tar.gz |
|---|---|
| Size | 154.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ef1098f2a0e68afe40349475018f7694b05bdf92250772cd8d0126f26de58a9
|
|
BLAKE2b-256 checksum How to use checksums |
4c126cbd6fc135a478ebc77e8ac2dd949a1c503d038a9181881a52c3e4ad6395
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|
Release files / redbird-0.7.1-py3-none-any.whl
| Download URL | redbird-0.7.1-py3-none-any.whl |
|---|---|
| Size | 60.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a1fe83fa9dfc0c5b9cb256b54376c299c423f2daba7bcbc081a820ff5b3c6c1
|
|
BLAKE2b-256 checksum How to use checksums |
b647af2f7054e12d038115adc51073d2ce280ee4f4e368ad5a085eb149504ced
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.1
|
Security for redbird 0.7.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.