RpRelPyDBRelational Python

In-memory relational objects for Python

RelPyDB lets Python code think relationally.

Define tables, columns, primary keys, foreign keys, joins, group-by queries, indexes, encrypted columns, persistence files and SQL exports directly in Python.

Zero setupNo server, no migrations5 join typesinner, left, right, full, cross6 export formatslist, JSON, pandas, NumPy, SQL, print
RelPyDB diagram
example.py
from relpy import RelPy, AutoNumber, col

db = RelPy()
db.create_table("users")
db.add_column("users", "id", AutoNumber, is_primary_key=True)
db.add_column("users", "name", str, nullable=False)
alice = db.insert("users", {"name": "Alice"})
db.insert_many("users", [{"name": "Bob"}, {"name": "Carol"}])
print(db.query("users").where(col("name") == "Alice").to_list())

Start Here

New developer path: mental model, first script and where to go next.

Open Start Here

Full tutorial

Build a small shop database with joins, grouping, indexes, persistence and encryption.

Open Tutorial
RelPyDB
rows = (
    db.query("orders")
      .join("users")
      .where(col("orders.status") == "paid")
      .select("orders.id", "users.name", "orders.amount")
      .to_list()
)
SQL equivalent
SELECT orders.id, users.name, orders.amount
FROM orders
JOIN users ON users.id = orders.user_id
WHERE orders.status = 'paid';

Start here

From quickstart to full API reference

RelPyDB ships with a quickstart, a full tutorial, topic docs for every feature, and a searchable API reference. All pages include runnable examples and SQL comparisons.