Documentation
1. 5-Minute Quickstart
Create your first table, insert one row with insert, add more rows with insert_many, query, save and load.
Quickstart in five minutes
This page is the shortest runnable path through RelPyDB. It creates a relational object, defines schema, inserts one row with insert, adds more rows with insert_many, queries rows, and saves the object to disk.
- Install from GitHub.
- Create a database object.
- Create typed tables.
- Insert dictionaries as rows with
insertorinsert_many. - Query with
coland terminal methods. - Save and load the object.
Install from GitHub
python -m pip install git+https://github.com/mandelreouven2002/RelPyDB.gitFor now, GitHub is the only supported installation method.
Complete first script
from relpy import RelPy, AutoNumber, col
# 1. Create an empty relational object.
db = RelPy()
# 2. Define a users table.
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")
# 3. Insert one row.
db.insert("users", {"name": "Alice"})
# 4. Insert many rows efficiently.
db.insert_many("users", [
{"name": "Bob", "status": "inactive"},
{"name": "Carol"},
{"name": "Dana"},
])
# 5. Query rows.
active_users = (
db.query("users")
.where(col("status") == "active")
.select("id", "name")
.to_list()
)
print(active_users)
# 6. Save the relational object.
db.save("quickstart.relpy.json")
# 7. Load it again.
loaded_db = RelPy.load("quickstart.relpy.json")
print(loaded_db.to_list("users"))Output
[{"id": 1, "name": "Alice"}, {"id": 3, "name": "Carol"}, {"id": 4, "name": "Dana"}]
[{"id": 1, "name": "Alice", "status": "active"}, {"id": 2, "name": "Bob", "status": "inactive"}, {"id": 3, "name": "Carol", "status": "active"}, {"id": 4, "name": "Dana", "status": "active"}]Why insert_many matters
Use insert when you add a single row. Use insert_many when you already have a list of dictionaries, such as JSON data, CSV rows, generated test data, or API results.
| Function | Best for | Input shape |
|---|---|---|
insert | One row | {"name": "Alice"} |
insert_many | Many rows | [{"name": "Alice"}, {"name": "Bob"}] |
users_from_api = [
{"name": "Alice"},
{"name": "Bob"},
{"name": "Carol"},
]
db.insert_many("users", users_from_api)What each line means
| Line | Meaning |
|---|---|
RelPy() | Creates the in-memory relational object. |
create_table | Creates an empty relation with a name. |
add_column | Adds schema: type, nullable rules, primary key flags, defaults and metadata. |
AutoNumber | Creates an auto-incrementing integer primary key. |
insert | Validates and stores one row. |
insert_many | Validates and stores a list of rows efficiently. |
query | Starts a chainable query builder. |
where | Filters rows. |
select | Projects specific columns. |
to_list | Executes the query and returns Python dictionaries. |
save/load | Serializes and restores the object. |