PrayDB

A Python database that stores JSON in an LLM context window and prays the answer is valid JSON.

What it is

PrayDB is a Python library and CLI. Everything lives in one JSON file. Writes are local (instant). Reads go through an AI model that looks at your data and answers.

Install

cd praydb
python3 -m pip install -e .

Env

export OPENROUTER_API_KEY="sk-or-..."
export PRAYDB_MODEL="provider/sacrifice_model"

CLI

praydb set timezone "GMT+3"
praydb set vibe "only PrayDB"
praydb get timezone
praydb dump
praydb delete vibe
praydb reset
praydb doctor

Database stored at ~/.praydb/db.json.

Python API

from praydb import PrayDB, Query

db = PrayDB(api_key="sk-or-...", model="openai/gpt-4o-mini")

db.set("timezone", "GMT+3")
db.set("vibe", {"ui": "squared", "chaos": "low"})
print(db.get("timezone"))

User = Query()
db.insert({"id": "user", "timezone": "GMT+3", "role": "admin"})
db.update({"role": "owner"}, User.id == "user")
print(db.search(User.timezone == "GMT+3"))
print(db.dump())

Architecture

1. One JSON file

All data lives in ~/.praydb/db.json.

2. Writes local

Set, delete, insert edit the JSON directly.

3. Reads via AI

Get, dump, search send the JSON to the model.

4. Validate

Bad JSON from the model is rejected.

Model settings

db = PrayDB(
    api_key="sk-or-...",
    model="openai/gpt-4o-mini",
    temperature=0,
    max_tokens=2048,
    retries=2,
)

Warnings

Do not store passwords, secrets, medical data, financial records, or anything that must survive reality. If the model lies, that is not a bug – that is the architecture.

Files

praydb/
  pyproject.toml
  README.md
  LICENSE
  examples/basic.py
  tests/test_core.py
  praydb/index.html
  src/praydb/
    __init__.py
    core.py
    cli.py
    py.typed