MCPcopy Index your code
hub / github.com/Miksus/red-bird

github.com/Miksus/red-bird @v0.7.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.7.1 ↗ · + Follow
496 symbols 2,203 edges 58 files 121 documented · 24%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Red Bird

Repository Patterns for Python

Generic database implemetation for SQL, MongoDB and in-memory lists


Pypi version build codecov Documentation Status PyPI pyversions

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

Core symbols most depended-on inside this repo

filter_by
called by 79
redbird/repos/mongo.py
all
called by 54
redbird/base.py
add
called by 54
redbird/base.py
select
called by 29
redbird/sql/expressions.py
get_field_value
called by 19
redbird/base.py
get_collection
called by 14
redbird/repos/mongo.py
update
called by 13
redbird/sql/expressions.py
create
called by 13
redbird/sql/expressions.py

Shape

Method 271
Function 152
Class 68
Route 5

Languages

Python100%

Modules by API surface

redbird/test/common/test_common.py51 symbols
redbird/sql/expressions.py50 symbols
redbird/base.py35 symbols
redbird/oper.py33 symbols
redbird/repos/sqlalchemy.py31 symbols
redbird/repos/mongo.py27 symbols
redbird/test/common/conftest.py24 symbols
redbird/test/repo/test_sql.py22 symbols
redbird/templates.py22 symbols
redbird/repos/json.py16 symbols
redbird/repos/rest.py14 symbols
redbird/repos/csv.py14 symbols

Datastores touched

(mongodb)Database · 1 repos
pytestDatabase · 1 repos
mydbDatabase · 1 repos

For agents

$ claude mcp add red-bird \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact