Skip to main content

dbe-engine

Lightweight, dependency-free database engine with Estonian-language SQL-like keywords, backed by a simple JSON file format (.dbe).

LOO TABEL kasutajad (id TÄISARV PÕHIVÕTI, nimi TEKST);
LISA TABELISSE kasutajad (id, nimi) VÄÄRTUSED (1, 'Mari');
VALI KÕIK TABELIST kasutajad KUS id = 1;

Live demo, web UI and HTTP API: https://databaas.ee/ (runnable code examples for PHP, Java, Python and Go: https://databaas.ee/naited.html)

Install

pip install dbe-engine

Usage

from dbe_engine.engine import Database
from dbe_engine import storage

path = "minu.dbe"
storage.save(path, storage.empty_database())

db = Database(path)
results = db.execute_script(
    "LOO TABEL kasutajad (id TÄISARV PÕHIVÕTI, nimi TEKST);"
    "LISA TABELISSE kasutajad (id, nimi) VÄÄRTUSED (1, 'Mari');"
    "VALI KÕIK TABELIST kasutajad;"
)
for r in results:
    print(r)

More examples

Filtering, sorting and limiting

db.execute_script(
    "LOO TABEL tooted (id TÄISARV PÕHIVÕTI, nimi TEKST, hind MURDARV, laos TÄISARV);"
    "LISA TABELISSE tooted (id, nimi, hind, laos) VÄÄRTUSED (1, 'Kohv', 4.5, 20);"
    "LISA TABELISSE tooted (id, nimi, hind, laos) VÄÄRTUSED (2, 'Tee', 3.2, 0);"
    "LISA TABELISSE tooted (id, nimi, hind, laos) VÄÄRTUSED (3, 'Kakao', 5.0, 8);"
)

# Only products in stock and cheaper than 5 euros, cheapest first
results = db.execute_script(
    "VALI nimi, hind TABELIST tooted KUS laos > 0 JA hind < 5 JÄRJESTA hind KASVAVALT;"
)
print(results[0]["rows"])  # [{'nimi': 'Kohv', 'hind': 4.5}]

Updating and deleting

db.execute_script(
    "UUENDA tooted MÄÄRA hind = 4.0, laos = 15 KUS nimi = 'Kohv';"
    "KUSTUTA TABELIST tooted KUS laos = 0;"
    "VALI KÕIK TABELIST tooted;"
)

Multiple tables, NULLs, ORDER BY + LIMIT together

db.execute_script(
    "LOO TABEL kliendid (id TÄISARV PÕHIVÕTI, nimi TEKST KOHUSTUSLIK, email TEKST);"
    "LOO TABEL tellimused (id TÄISARV PÕHIVÕTI, kliendi_id TÄISARV, summa MURDARV);"
    "LISA TABELISSE kliendid (id, nimi, email) VÄÄRTUSED (1, 'Mari Maasikas', TÜHI);"
    "LISA TABELISSE tellimused (id, kliendi_id, summa) VÄÄRTUSED (1, 1, 49.90);"
    "LISA TABELISSE tellimused (id, kliendi_id, summa) VÄÄRTUSED (2, 1, 120.50);"
    # biggest order overall
    "VALI KÕIK TABELIST tellimused JÄRJESTA summa KAHANEVALT PIIRA 1;"
    "NÄITA TABELEID;"
    "KIRJELDA tellimused;"
)

Schema and table introspection

db.execute_script("NÄITA TABELEID;")   # SHOW TABLES
db.execute_script("KIRJELDA tooted;")  # DESCRIBE

Every execute_script() call returns a list of per-statement results, each shaped like {"ok": True, "type": "rows"|"info", "columns"/"rows" or "message"/"error"} — the same JSON shape returned by the HTTP API on https://databaas.ee/.

Supported commands

Eesti keeles SQL vaste
LOO TABEL nimi (veerg TÜÜP [PÕHIVÕTI] [KOHUSTUSLIK], ...) CREATE TABLE
KUSTUTA TABEL nimi DROP TABLE
NÄITA TABELEID SHOW TABLES
KIRJELDA nimi DESCRIBE
LISA TABELISSE nimi (...) VÄÄRTUSED (...) INSERT INTO
VALI veerud TABELIST nimi [KUS ...] [JÄRJESTA ...] [PIIRA ...] SELECT
UUENDA nimi MÄÄRA veerg = väärtus [KUS ...] UPDATE
KUSTUTA TABELIST nimi [KUS ...] DELETE FROM

Types: TÄISARV (int), MURDARV (float), TEKST (text), TÕEVÄÄRTUS (bool).

License

MIT

Metadata

Release files for dbe-engine 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbe-engine 0.1.1
File Size Uploaded
dbe_engine-0.1.1.tar.gz 12.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dbe-engine 0.1.1
File Interpreter ABI Platform
dbe_engine-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 24.3 kB

Release files / dbe_engine-0.1.1.tar.gz

Download URL dbe_engine-0.1.1.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
84560322918ddba4c62b1df30fb32a01479f87dcf026a1e74a16041a1460d4d0
BLAKE2b-256 checksum
How to use checksums
478c8e27946354fe6685a3a979ece9070adbab9854999a32ec20463f15226c37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / dbe_engine-0.1.1-py3-none-any.whl

Download URL dbe_engine-0.1.1-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc1058df9524a16f0054c8302f33f22ddf7d527d4d236f1247381a8a1c74b572
BLAKE2b-256 checksum
How to use checksums
017841e0b51d7aeb55de0e20429229e32f54b66f7950768a39f2b03c5bd0ec85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page