Documentation
0. Start Here
A guided entry point for new developers who want to understand how to use RelPyDB.
Start here
RelPyDB is easiest to learn as a small relational database object inside Python. The basic flow is simple: create a database object, define schema, insert rows, query, export, and optionally save the object.
- Create a
RelPy()object. - Create tables with
create_table. - Add columns with
add_column. - Insert one row with
insertor many rows withinsert_many. - Query with
db.query(...),where,select, joins, and grouping. - Export with
to_list,to_json,to_pandas,to_numpy,to_sql, orto_ddl. - Save and load with
saveandRelPy.load.
The mental model
Think of RelPyDB as a Python object that contains relational tables. It is not a server and it is not a full SQL engine. You work with normal Python code, but the data has relational structure.
RelPy object
├── schema
│ ├── tables
│ ├── columns
│ ├── primary keys
│ └── foreign keys
├── data rows
├── indexes
├── views
├── query builder
└── exports / persistenceThe first thing to read
| Goal | Read this | Why |
|---|---|---|
| I want to run code now | 5-Minute Quickstart | Small complete script with insert, then insert_many, query, output, save and load. |
| I want to build a realistic model | Full Tutorial | Users, orders, support tickets, joins and grouping. |
| I have a specific task | Common Recipes | Copyable patterns for common use cases. |
| I want every function | Function Reference | Inputs, outputs, imports, examples and notes. |
Small complete example
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)
db.add_column("users", "status", str, nullable=False, default="active")
db.insert("users", {"name": "Alice"})
db.insert_many("users", [
{"name": "Bob", "status": "inactive"},
{"name": "Carol"},
])
active_users = (
db.query("users")
.where(col("status") == "active")
.select("id", "name")
.to_list()
)
print(active_users)Output
[{"id": 1, "name": "Alice"}, {"id": 3, "name": "Carol"}]