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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbe_engine-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbe_engine-0.1.1-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file dbe_engine-0.1.1.tar.gz.

File metadata

  • Download URL: dbe_engine-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.11

File hashes

Hashes for dbe_engine-0.1.1.tar.gz
Algorithm Hash digest
SHA256 84560322918ddba4c62b1df30fb32a01479f87dcf026a1e74a16041a1460d4d0
MD5 50affdbbb1a266e3f182258f9c1d26cf
BLAKE2b-256 478c8e27946354fe6685a3a979ece9070adbab9854999a32ec20463f15226c37

See more details on using hashes here.

File details

Details for the file dbe_engine-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dbe_engine-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.11

File hashes

Hashes for dbe_engine-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc1058df9524a16f0054c8302f33f22ddf7d527d4d236f1247381a8a1c74b572
MD5 02bbadb43cfd764a07d99d2ce09b3055
BLAKE2b-256 017841e0b51d7aeb55de0e20429229e32f54b66f7950768a39f2b03c5bd0ec85

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 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