Skip to main content

Python bindings for the Lora in-memory graph database

Project description

lora-python

Python bindings for the Lora graph engine. Ships both a synchronous PyO3 Database class and an asyncio-compatible AsyncDatabase wrapper that never blocks the event loop.

Status: prototype / feasibility check. Not published to PyPI.

Install (local dev)

cd crates/lora-python
python3 -m venv .venv && source .venv/bin/activate
pip install -U pip maturin pytest pytest-asyncio
maturin develop         # builds the Rust extension into the venv
pytest                  # runs the sync + async smoke tests

maturin develop produces a lora_python/_native.<platform>.so inside the package and makes import lora_python work immediately.

Sync usage

from lora_python import Database, is_node

db = Database.create()
db.execute("CREATE (:Person {name: $n, age: $a})", {"n": "Alice", "a": 30})

res = db.execute("MATCH (n:Person) RETURN n")
for row in res["rows"]:
    n = row["n"]
    if is_node(n):
        print(n["properties"]["name"])

Initialization rule:

from lora_python import Database

scratch = Database.create()            # in-memory
persistent = Database.create("./app")  # persistent: directory string

If you want persistence, pass a directory string to Database.create(...) or Database(...).

Async usage (non-blocking)

import asyncio
from lora_python import AsyncDatabase

async def main():
    db = await AsyncDatabase.create()
    await db.execute("CREATE (:Person {name: 'Alice'})")
    r = await db.execute("MATCH (n:Person) RETURN n.name AS name")
    print(r["rows"])

asyncio.run(main())

Async initialization follows the same rule:

db = await AsyncDatabase.create()            # in-memory
db = await AsyncDatabase.create("./app")     # persistent: directory string

AsyncDatabase.execute dispatches the query onto the default asyncio thread pool via asyncio.to_thread. The PyO3 Database.execute releases the Python GIL for the duration of engine work, so other coroutines on the event loop can progress while a query runs. A dedicated test proves the event loop continues ticking during a 2 000-node MATCH.

Typed value model

Same conceptual contract as lora-node / lora-wasm:

Python shape Lora value
None, bool, int, float, str scalars
list, dict collections
{"kind": "node", "id", "labels", "properties"} node
{"kind": "relationship", "id", …} relationship
{"kind": "path", "nodes": [...], "rels": [...]} path
{"kind": "date", "iso": "YYYY-MM-DD"} (and time, …) temporal
point dicts — see below point

Points are returned as dicts keyed on their CRS:

SRID Dict
7203 {"kind": "point", "srid": 7203, "crs": "cartesian", "x", "y"}
9157 {"kind": "point", "srid": 9157, "crs": "cartesian-3D", "x", "y", "z"}
4326 {"kind": "point", "srid": 4326, "crs": "WGS-84-2D", "x", "y", "longitude", "latitude"}
4979 {"kind": "point", "srid": 4979, "crs": "WGS-84-3D", "x", "y", "z", "longitude", "latitude", "height"}

Constructors and guards are exported from lora_python.types: date, time, localtime, datetime, localdatetime, duration, cartesian, cartesian_3d, wgs84, wgs84_3d, is_node, is_relationship, is_path, is_point, is_temporal.

distance() on WGS-84-3D points ignores height — see functions reference for the full spatial reference and known limitations.

Errors

  • LoraError — base class
  • LoraQueryError — parse / analyze / execute failure
  • InvalidParamsError — a parameter value couldn't be mapped

All three are available as lora_python.LoraError, etc.

Persistence

Database.create("./app"), Database("./app"), and await AsyncDatabase.create("./app") open or create a WAL-backed persistent database rooted at that directory. Reopening the same path replays committed writes before returning the handle.

Call db.close() / await db.close() before reopening the same WAL directory inside one process.

This first Python persistence slice intentionally stays small: the binding exposes WAL-backed initialization plus the existing save_snapshot / load_snapshot APIs, but not checkpoint, truncate, status, or sync-mode controls.

Architecture

lora-database (Rust)
   └── lora-python (crate, cdylib)             <- PyO3 bindings
          ├── Database (sync, releases the GIL)
          └── python/lora_python/
                 ├── _async.py  AsyncDatabase via asyncio.to_thread
                 └── types.py   typed dicts + constructors + guards

Project details


Download files

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

Source Distribution

lora_python-0.4.0.tar.gz (335.6 kB view details)

Uploaded Source

Built Distributions

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

lora_python-0.4.0-cp38-abi3-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.8+Windows x86-64

lora_python-0.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

lora_python-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

lora_python-0.4.0-cp38-abi3-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

lora_python-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file lora_python-0.4.0.tar.gz.

File metadata

  • Download URL: lora_python-0.4.0.tar.gz
  • Upload date:
  • Size: 335.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lora_python-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e8e6371e3dc6acf42874bb26362b1a3804eb0b82b9cfd951698e477d45730453
MD5 8d9b8ce731359997b1867052ba2af6ad
BLAKE2b-256 ae1c912b8c25ce2648f20d6f41c9f7576cbff76f9c1f1a1a9c1c3dae7aebfcaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for lora_python-0.4.0.tar.gz:

Publisher: packages-release.yml on lora-db/lora

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lora_python-0.4.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: lora_python-0.4.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lora_python-0.4.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 47f2d2daa87bde39b074e0e940b33c97cbf2c115c4a51181168ca9608e49ed1b
MD5 847d78ad6dd5b9e520751d0119abecd6
BLAKE2b-256 a2f1d830458b68cf11a8c66e34e145be23a498f0fbf50434f9b4e79a170902b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for lora_python-0.4.0-cp38-abi3-win_amd64.whl:

Publisher: packages-release.yml on lora-db/lora

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lora_python-0.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lora_python-0.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a89388deb3a66bb7d7a55ea189f81492b15188547ee6a85a17a14c253fb00817
MD5 1bf16ecbab45cd19af28176c21811c35
BLAKE2b-256 b08a581a7d092e029d51f60db0ee6377c0afd2da0ba20c5e6df4e169d16100b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for lora_python-0.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: packages-release.yml on lora-db/lora

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lora_python-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for lora_python-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 98155cd1462766cef751a6a606902199b74ff6e7a97f1c9169103f59a152507b
MD5 d656c732edc270c62f04b7b12d0612df
BLAKE2b-256 d9d0511c83c521cc8277806608412fc7a0d9b3f41a6852dd9eb9372466ab9506

See more details on using hashes here.

Provenance

The following attestation bundles were made for lora_python-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: packages-release.yml on lora-db/lora

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lora_python-0.4.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lora_python-0.4.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6ca4a41c46a5a11655f5a272592dea4bfea692e89685ee8d41dd25a51059246
MD5 6eb8bd184a5b9a75b73d432bbddaabfc
BLAKE2b-256 f0fcdae429ed71a56bbfd3622433e5d7feba8e423cb4ed2bbf412c16c0892fe1

See more details on using hashes here.

Provenance

The following attestation bundles were made for lora_python-0.4.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: packages-release.yml on lora-db/lora

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lora_python-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for lora_python-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 75c6ed5a737060d6039832b3216cd57c1a42c99df0241c2faf43f23b1bf566cf
MD5 3f99dee8e752d5cff399bcbc966c9e37
BLAKE2b-256 e0912b4b562485a9d357640a32ec97de00e04986b9521f596f741022b5175287

See more details on using hashes here.

Provenance

The following attestation bundles were made for lora_python-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: packages-release.yml on lora-db/lora

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page