A MySQL-compatible database engine for Python — now with Vector Search, Time-Series, REST API, and full AI Ecosystem integration.
KonaDB is a lightweight, zero-dependency database engine that supports full MySQL SQL syntax, MongoDB-style document collections, ACID transactions, file-based persistence, vector similarity search, time-series storage, and a built-in REST API server — all powered by Python, no external database needed.
| Feature | Description |
|---|---|
| Full MySQL SQL | CREATE, INSERT, SELECT, UPDATE, DELETE, JOINs, GROUP BY, subqueries, and more |
| Document Store | MongoDB-style JSON collections with query operators |
| ACID Transactions | Snapshot isolation with context manager support |
| File Persistence | .kona files (gzip-compressed JSON) with atomic writes |
| Vector Store | kona.vector — cosine similarity search, multi-namespace, embedding storage |
| Time-Series | kona.timeseries — OHLCVA-compatible, windowed aggregations (avg/min/max/ohlc) |
| REST API Server | kona serve mydb.kona — full HTTP REST API with JSON responses |
| AI Features | Natural language queries, query optimization, schema design, anomaly detection |
| Interactive CLI | kona mydb.kona — full-featured REPL with tabular output |
| Zero Dependencies | Core engine has no external dependencies |
| Import/Export | CSV and JSON import/export |
| Ecosystem Hub | Shared data layer for RAG Engine, Sentiment Dashboard, Kronos, AI SQL |
pip install -e .import kona
# Connect to in-memory or file-based database
conn = kona.connect(":memory:") # in-memory
conn = kona.connect("mydb.kona") # persistent file
# Create tables
conn.execute("""
CREATE TABLE users (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE,
age INT DEFAULT 0
)
""")
# Insert and query
conn.execute("INSERT INTO users (name, email, age) VALUES ('Alice', 'alice@example.com', 30)")
rows = conn.execute("SELECT * FROM users WHERE age > 20 ORDER BY name")
conn.close()kona mydb.kona╔═══════════════════════════════════════╗
║ KonaDB Shell v1.0.0 ║
║ MySQL-compatible Database Engine ║
╚═══════════════════════════════════════╝
kona> CREATE TABLE items (id INT PRIMARY KEY, name TEXT);
Table 'items' created.
kona> SELECT * FROM items;
+----+--------+
| id | name |
+----+--------+
| 1 | Widget |
| 2 | Gadget |
+----+--------+
2 row(s) in set
Use KonaDB as a lightweight vector database — perfect for RAG applications.
from kona.vector import VectorStore
import kona
conn = kona.connect("mydb.kona")
vs = VectorStore(conn, namespace="docs")
# Add document embeddings
vs.add(
embedding=[0.1, 0.4, 0.9, ...], # your embedding vector
text="KonaDB supports vector search natively",
metadata={"source": "docs.md", "chunk": 1}
)
# Similarity search
results = vs.search(query_embedding=[0.1, 0.4, 0.8, ...], top_k=5)
for r in results:
print(f"[{r.score:.3f}] {r.text}")
# Batch insert
vs.add_batch([
{"embedding": vec1, "text": "...", "metadata": {"source": "a"}},
{"embedding": vec2, "text": "...", "metadata": {"source": "b"}},
])Integrates directly with RAG-GraphRAG-Knowledge-Engine — use KonaDB as an alternative to FAISS for fully persistent vector storage.
Optimized append-only storage for financial data, metrics, and sentiment streams.
from kona.timeseries import TimeSeries
import kona
conn = kona.connect("market.kona")
ts = TimeSeries(conn, name="btc_price", retention_days=90)
# Insert data points
ts.insert_now(value=42000.0, tags={"exchange": "binance", "pair": "BTC/USD"})
# Kronos-compatible OHLCVA format
ts.insert_ohlcva(open=42000, high=43500, low=41800, close=43000,
volume=1200.5, amount=51.2)
# Query last hour
points = ts.range(start=time.time() - 3600)
# 1-hour OHLC candles
candles = ts.aggregate(window=3600, func="ohlc")Integrates with Kronos for financial experiment result persistence and Sentiment Dashboard for emotion time-series storage.
Expose any .kona database as a full HTTP API — no extra code needed.
# Start the server
kona serve mydb.kona --port 5432
# Or via Python
python -m kona.server mydb.kona --port 5432╔══════════════════════════════════════════╗
║ KonaDB REST Server v1.0.0 ║
║ ║
║ Database : mydb.kona ║
║ API : http://0.0.0.0:5432 ║
╚══════════════════════════════════════════╝
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
GET |
/tables |
List all tables |
POST |
/query |
Execute SQL query |
POST |
/tables/{table}/rows |
Insert row(s) |
GET |
/tables/{table}/rows |
Select rows (with ?where=&limit=) |
POST |
/vector/add |
Add embedding to vector store |
POST |
/vector/search |
Cosine similarity search |
POST |
/timeseries/{series} |
Insert time-series point |
GET |
/timeseries/{series} |
Query time-series range |
POST |
/ai/query |
Natural language → SQL |
# Example: SQL query
curl -X POST http://localhost:5432/query \
-H "Content-Type: application/json" \
-d '{"sql": "SELECT * FROM users LIMIT 5"}'
# Example: Vector search
curl -X POST http://localhost:5432/vector/search \
-H "Content-Type: application/json" \
-d '{"namespace": "docs", "embedding": [0.1, 0.4, ...], "top_k": 3}'
# Example: NL query
curl -X POST http://localhost:5432/ai/query \
-d '{"question": "How many users signed up this week?"}'CREATE TABLE t (col1 TYPE, col2 TYPE, ...);
CREATE TABLE IF NOT EXISTS t (...);
DROP TABLE t;
ALTER TABLE t ADD COLUMN col TYPE;
ALTER TABLE t DROP COLUMN col;
CREATE INDEX idx ON t (col1, col2);
CREATE UNIQUE INDEX idx ON t (col);
CREATE VIEW v AS SELECT ...;
TRUNCATE TABLE t;
RENAME TABLE old TO new;INSERT INTO t (col1, col2) VALUES (v1, v2);
INSERT INTO t VALUES (v1, v2); -- positional
UPDATE t SET col = val WHERE ...;
DELETE FROM t WHERE ...;
SELECT col1, col2 FROM t
WHERE col > 5
GROUP BY col1
HAVING COUNT(*) > 1
ORDER BY col2 DESC
LIMIT 10 OFFSET 5;
SELECT t1.*, t2.name FROM t1 JOIN t2 ON t1.id = t2.fk;
SELECT * FROM t WHERE id IN (SELECT id FROM t2 WHERE ...);INT, INTEGER, BIGINT, FLOAT, DOUBLE, VARCHAR(N), TEXT, BLOB, BOOLEAN, DATE, DATETIME, TIMESTAMP, JSON
with conn.transaction():
conn.execute("UPDATE accounts SET balance = balance - 100 WHERE id = 1")
conn.execute("UPDATE accounts SET balance = balance + 100 WHERE id = 2")
# auto-committed on exit, auto-rolled-back on exception# Create a collection
conn.create_collection("events")
# Insert documents
conn.insert_document("events", {"type": "click", "user": "alice", "ts": 1700000000})
# Query with MongoDB-style operators
docs = conn.find("events", {"type": "click", "user": {"$in": ["alice", "bob"]}})
# Update and delete
conn.update_documents("events", {"type": "click"}, {"$set": {"processed": True}})
conn.delete_documents("events", {"processed": True})KonaDB serves as the unified data layer for the entire Kona AI Ecosystem:
┌──────────────────────────────────────────────────────────────┐
│ KONA AI ECOSYSTEM │
│ │
│ RAG Engine ──────────────────────┐ │
│ (vector embeddings → KonaDB) │ │
│ ▼ │
│ Sentiment Dashboard ─────► KonaDB ◄─── AI SQL Analyst │
│ (emotion time-series) (Hub) (kona:// backend) │
│ ▲ │
│ Kronos ──────────────────────────┘ │
│ (OHLCVA results → KonaDB) │
└──────────────────────────────────────────────────────────────┘
# Example: RAG Engine using KonaDB as vector backend
from kona.vector import VectorStore
import kona
conn = kona.connect("ecosystem.kona")
rag_store = VectorStore(conn, namespace="rag_docs")
# Example: Sentiment Dashboard storing emotions in KonaDB
from kona.timeseries import TimeSeries
joy_ts = TimeSeries(conn, name="sentiment_joy", retention_days=30)
joy_ts.insert_now(value=0.87, tags={"source": "twitter", "topic": "BTC"})
# Example: Kronos storing experiment results
kronos_ts = TimeSeries(conn, name="kronos_forecast_btc")
kronos_ts.insert(value=44200.0, tags={"model": "kronos", "horizon": "1d"})pytest tests/ -vdocker build -t kona-db .
docker run -p 5432:5432 -v $(pwd)/data:/data kona-db serve /data/mydb.kona| Project | Role in Ecosystem |
|---|---|
| RAG-GraphRAG-Knowledge-Engine | Uses KonaDB as vector store backend |
| Real-time-Sentiment-Intelligence-Dashboard | Stores emotion time-series in KonaDB |
| kronos-reproduction | Persists OHLCVA experiment results in KonaDB |
| AI-SQL-Data-Analyst | Supports kona:// connection string |
| Agentic-Code-Review-Bot | Stores review history in KonaDB |
MIT © konaaravind4