YesDB
Beta — A lightweight relational database built from scratch in Python, with SQL support, B-tree storage, and a cloud Backend-as-a-Service. Ready to use for real projects; still under active development, so expect the occasional rough edge.
Installation
# Local only
pip install yesdb
# With cloud support
pip install yesdb[cloud]
Quick Start
Local Mode
from yesdb import connect
db = connect("myapp.db")
db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)")
db.execute("INSERT INTO users VALUES (NULL, 'Alice', 30)")
results = db.execute("SELECT * FROM users")
for row in results:
print(row)
db.close()
Cloud Mode
YesDB Cloud lets you host your database on a remote server. Perfect for student projects that need a real backend.
1. Sign up and create a database
yesdb signup
# Email: student@uni.edu
# Password: ********
# -> Account created! Logged in.
yesdb init myproject
# -> Created yesdb/ folder with schema.py
# -> Database "myproject" created on cloud.
2. Define your schema
After running yesdb init, you'll have a yesdb/schema.py file in your project. Edit it:
# yesdb/schema.py
from yesdb import Table, Column, Integer, Text, Real
users = Table("users", [
Column("id", Integer, primary_key=True),
Column("name", Text),
Column("email", Text),
])
products = Table("products", [
Column("id", Integer, primary_key=True),
Column("name", Text),
Column("price", Real),
])
3. Push your schema to the cloud
yesdb push
# -> Connecting to myproject database...
# -> Table "users" created
# -> Table "products" created
# -> Schema synced. 2 tables pushed.
4. Use in your code
from yesdb import connect
db = connect("myproject") # uses saved credentials automatically
db.execute("INSERT INTO users VALUES (NULL, 'Alice', 'alice@uni.edu')")
db.execute("INSERT INTO users VALUES (NULL, 'Bob', 'bob@uni.edu')")
rows = db.execute("SELECT * FROM users")
for row in rows:
print(row)
Every response includes the database engine's internal logs (B-tree operations, SQL parsing, page allocations), so you can see exactly what's happening under the hood.
5. Use with FastAPI or Flask
# main.py
from fastapi import FastAPI
from yesdb import connect
app = FastAPI()
db = connect("myproject")
@app.get("/users")
def get_users():
rows = db.execute("SELECT * FROM users")
return {"users": [list(row) for row in rows]}
@app.post("/users")
def create_user(name: str, email: str):
db.execute(f"INSERT INTO users VALUES (NULL, '{name}', '{email}')")
return {"status": "created"}
CLI Commands
yesdb signup # Create an account
yesdb login # Login to existing account
yesdb init <db_name> # Initialize a project with a cloud database
yesdb push # Push schema.py to the cloud
yesdb databases # List your databases
yesdb shell <db_name> # Interactive SQL shell against a cloud database
Local CLI Shell
yesdb-local mydatabase.db
YesDB> CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER);
YesDB> INSERT INTO users VALUES (NULL, 'Alice', 30);
YesDB> SELECT * FROM users;
.help Show help
.tables List all tables
.schema Show table schemas
.exit Exit shell
Features
- SQL Support: CREATE, SELECT, INSERT, UPDATE, DELETE, DROP, ALTER TABLE
- Data Types: INTEGER, TEXT, REAL, BLOB
- Query Features: WHERE, ORDER BY, LIMIT, OFFSET, DISTINCT
- B-Tree Storage: Efficient indexing and data retrieval
- No Dependencies: Pure Python implementation (local mode)
- Cloud BaaS: Host your database remotely with a single command
- Schema DSL: Define tables in Python, push to cloud
- Engine Logs: See B-tree splits, page allocations, and SQL parsing in every response
- Interactive Shell: Built-in SQL shell (local and cloud)
- Auto-increment: PRIMARY KEY auto-increment support
SQL Examples
-- Create table
CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT, age INTEGER)
-- Insert data
INSERT INTO users VALUES (NULL, 'Alice', 'alice@example.com', 30)
INSERT INTO users VALUES (NULL, 'Bob', 'bob@example.com', 25)
-- Query with conditions
SELECT * FROM users WHERE age > 25
SELECT name, email FROM users WHERE name = 'Alice'
-- Order and limit
SELECT * FROM users ORDER BY age DESC
SELECT * FROM users LIMIT 10 OFFSET 5
-- Update and delete
UPDATE users SET age = 31 WHERE name = 'Alice'
DELETE FROM users WHERE age < 18
-- Alter table
ALTER TABLE users ADD COLUMN country TEXT
-- Drop table
DROP TABLE users
How Cloud Mode Works
Your machine YesDB Cloud Server
──────────────── ──────────────────
yesdb CLI (signup/login/push) ┌─────────────────┐
<-> HTTPS │ Tailscale Funnel │
yesdb SDK (connect/execute) │ └─ FastAPI │
│ ├─ auth │
│ └─ data/ │
│ ├─ user1/ │
│ │ └─ *.db │
│ └─ user2/ │
│ └─ *.db │
└─────────────────┘
The server can run on any machine reachable over Tailscale — a cloud VM, a
home desktop, whatever's available. Tailscale Funnel handles public HTTPS
without opening router ports or managing a domain/certificate. See
deploy/setup.sh.
- Each user gets their own isolated account with multiple databases
- All traffic is encrypted over HTTPS
- Authentication via API key (generated at signup, saved locally)
- Database engine logs are returned with every query for full transparency
Security
Local Mode
- Path validation (blocks system file access)
- Resource limits (SQL length, record size)
- Input validation (table/column names)
Cloud Mode
- HTTPS encryption (TLS via Let's Encrypt)
- API key authentication (SHA-256 hashed, never stored in plaintext)
- Password hashing (bcrypt)
- Per-user data isolation
- Request size limits
Development
Install from Source
git clone https://github.com/AzharAhmed-bot/yes_db.git
cd yes_db
pip install -e ".[cloud]"
Run Tests
pip install pytest
pytest
Requirements
- Python 3.8+
- No external dependencies (local mode)
requests(cloud mode, installed withpip install yesdb[cloud])
License
MIT License - see LICENSE file
Links
- PyPI: https://pypi.org/project/yesdb/
- GitHub: https://github.com/AzharAhmed-bot/yes_db
- Issues: https://github.com/AzharAhmed-bot/yes_db/issues
Version
Current version: 0.2.4 (Beta)
Changelog
v0.2.4
- Changed: Dropped "educational" framing everywhere (PyPI classifiers/keywords, package docstring, README, SECURITY.md) in favor of a clear Beta positioning — YesDB is usable for real projects now, not just a teaching toy.
- New: Proper intro banners —
yesdb signup,yesdb-local <db>, andyesdb shell <db>now show the product name, version, and Beta status on first touch.signupalso points you to the next step (yesdb init). - Fix: The Cloud server's
/docspage showed a hardcoded, never-updated0.1.0API version — now reads the real package version. - Removed a stale, unreferenced duplicate README (
readME.md) left over from a very early pre-rename version of the project.
v0.2.3
- Fix:
SELECT ... WHERE ...(without ORDER BY/LIMIT/DISTINCT/GROUP BY) silently returned wrong data — the WHERE clause never actually resolved column values, and column projection (SELECT col FROM t) returned full rows instead of the requested columns. Both now go through the same correct execution path as every other SELECT variant. - Fix: Error messages were being needlessly hidden in production mode —
sanitize_error_message()collapsed every error down to generic strings like "Invalid input" or "An error occurred," including safe, expected ones (table already exists, unknown table, SQL syntax errors). Added aQueryErrorclass for errors that only ever echo back names/tokens the caller already supplied — these now show their real message instead of being sanitized away. - Improved:
yesdb pushoutput redesigned — one line per table with a real status (created / already exists, skipped / failed: reason) and an accurate summary, instead of a misleading "Table 'X' created" claim for every table regardless of outcome. Raw engine logs moved behind a new--verbose/-vflag. - Fix: logs captured before a statement failed during
pushwere silently dropped instead of reaching--verboseoutput.
v0.2.2
- Fix:
yesdb pushclaimed every table in your localschema.pywas "created" even when the server rejected some of them (e.g. re-pushing after a table already exists). The real per-table result was already shown via engine logs; the misleading summary line is now removed.
v0.2.1
- Fix:
yesdb signup/yesdb logindefault server URL pointed at a dead Azure endpoint (no longer hosted). Now points at the live, self-hosted Cloud instance. - Fix: Package metadata (
pyproject.toml,setup.cfg) and README referenced the wrong GitHub repo name (yesdbinstead ofyes_db), producing broken links.
v0.2.0 (Beta)
- New:
GROUP BYwith aggregate functions —COUNT,COUNT(*),SUM,AVG,MIN,MAX, combinable withWHERE,ORDER BY, andLIMIT/OFFSET. - Fix: Cloud server connection pool had a race condition — concurrent requests could open duplicate connections to the same database, or run unsynchronized queries against it, risking corruption. Access per database is now serialized.
- New: Query execution timeout on the cloud server (default 10s, configurable via
YESDB_QUERY_TIMEOUT_SECONDS) so a slow query can't block every other user of that database indefinitely. - Status: Moved from Alpha to Beta. Local Mode is beta-ready; Cloud Mode is deployed and live (self-hosted, see Cloud Mode section).
v0.1.5 (bug fixes)
- Fix:
from yesdb import connectnow works correctly. Ayesdbcompatibility package is included so the import matches the PyPI package name. - Fix:
Table.to_sql()now emits thePRIMARY KEYconstraint in the generatedCREATE TABLESQL, so auto-increment works as expected when insertingNULLinto a primary key column.
Note: YesDB is in active beta. It's built from scratch in Python and usable today for real projects and prototypes — you'll also see exactly how a database works internally along the way. Report issues on GitHub; for workloads with strict production/security requirements, an established database (PostgreSQL, MySQL, SQLite) is still the safer choice for now.
Metadata
Release files for yesdb 0.2.4
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 | |
|---|---|---|---|---|
| yesdb-0.2.4.tar.gz | 89.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yesdb-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 147.2 kB
Release files / yesdb-0.2.4.tar.gz
| Download URL | yesdb-0.2.4.tar.gz |
|---|---|
| Size | 89.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1578f78158297a736077ea52041b51cc0f5c81442c6b3a0e1be0a3e8a763ef5
|
|
BLAKE2b-256 checksum How to use checksums |
728fa033ebbdc813d41552e53b0a1633aa689e9fab04eade11be338343ba87a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / yesdb-0.2.4-py3-none-any.whl
| Download URL | yesdb-0.2.4-py3-none-any.whl |
|---|---|
| Size | 57.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1681ceeba3c9406c8c16f6f9fcf5b6469bbe5dc74a43965003907ccbaecc9d28
|
|
BLAKE2b-256 checksum How to use checksums |
b33f19dadc9bb127319dbe0be5021c3b49387605e15e3159a07896b5a1127617
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for yesdb 0.2.4
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.