Python binding (PyO3) for the rust-store multi-backend data engine: GQL parsing, permissions, computed columns and SQL dialect translation for MongoDB, MySQL, SQLite and PostgreSQL
Actively maintained. Last release 12 days ago, commits in 12 of the last 26 weeks. A safe choice.
pip install rust-store-pyrust-store-py
rust-store 的 Python 绑定(PyO3):把 Rust core 的 Command 契约暴露给 Python Host。
- 语言无关核心见
../core(GQL / 权限 / 计算列 / 命令规划 / SQL 方言翻译,纯逻辑无 IO)。 - 绑定层只做「dict in → dict out」的类型转换与转发,不持有数据库驱动,不执行任何 IO。
- Node 侧同构绑定见
../core-node(rust-store-node)。
安装
pip install rust-store-py
使用
from rust_store_py import Registry
reg = Registry()
reg.register({"name": "User", "collection": "users", "fields": {"name": {"type": "string"}}, "relations": {}})
plan = reg.plan_query("User{name}", {}, None) # → Mongo 命令 JSON(dict)
同步计算列回调经 set_fn 注册;异步计算列(asyncFn)由 Host 走 prepare_query / strip_query 两段式执行。
错误一律以异常抛出(PyErr),不会以返回值形式混进结果 dict。
命名规范与翻译摘要
归一实现唯一在 core::naming,经 core-node / core-py 透出,宿主不得重复实现。本语言(Python)归一匹配示例:实现 order_total ↔ 逻辑 Order.total。
Naming: freeform definitions, system-directed translation
Definitions (collection, fields, referenced relation fields, computed-column keys, fnRef values, index names) may use any style; the engine translates them to the target style. Contract keys (fnRef, localField, foreignField, asyncFn, type, ...) and the schema name are never translated.
| Target | Style | Example (orderTotal) |
|---|---|---|
| MySQL / PostgreSQL / SQLite (physical) | snake_case | order_total |
| MongoDB (physical) | camelCase | orderTotal |
| Node.js / Java / C# / Rust (code; computed columns follow) | camelCase | orderTotal |
| Go (code; computed columns follow) | PascalCase (must be exported) | OrderTotal |
| Python (code; computed columns follow) | snake_case | order_total |
Canonicalization (single implementation , re-exported by the bindings; hosts must not re-implement it): split on , , , space and at lower/digit-to-upper boundaries; a trailing uppercase in a run followed by a lowercase starts the next token ( -> , -> ); digits stay inside a token ( -> ). Reassembly: snake = , camel = , pascal = .