Perry native package: Prisma ORM backed by sqlx + SQLite.
Drop-in replacement for @prisma/client using sqlx with SQLite. Sibling of perry-prisma (MySQL) and perry-postgres — same architecture, ~95% identical code.
TypeScript → JSON string → FFI → Rust dispatcher → sqlx (SQLite) → JSON result → TypeScript
native/src/lib.rs— All Rust logic: query builder, row-to-JSON conversion, FFI exportsnative/build.rs— Readsprisma/schema.prismaat build time, generatesgenerated_models.rswith model metadatanative/Cargo.toml— Crate config; sqlx withsqlitefeaturesrc/index.ts— TypeScript layer:PrismaClient,ModelClient, type definitions, FFI declarationsperry.config.ts— Perry compiler configurationpackage.json— Package metadata, FFI function declarations, platform lib requirements
PRISMA_SCHEMA_PATHenv var../../../chainblick/api/prisma/schema.prisma(relative tonative/)- Falls back to empty model list with compile warning
- Pool type:
SqlitePool(notMySqlPool) - Identifier quoting:
"col"double quotes (not`col`backticks) - Placeholders:
?(same as MySQL) - Last insert ID:
last_insert_rowid()(notlast_insert_id()) - Transactions:
BEGIN/COMMIT/ROLLBACK(notSET autocommit=0; START TRANSACTION) - Boolean binding:
q.bind(*b)native bool (notq.bind(*b as i8)) - Skip duplicates:
INSERT OR IGNORE(notINSERT IGNORE) - Unlimited offset:
LIMIT -1 OFFSET n(notLIMIT 18446744073709551615 OFFSET n) - No TLS libs: SQLite is local — no
Security/SystemConfigurationframeworks on iOS, no crypto libs on Windows
All exported as sqlite_*:
| Function | Signature |
|---|---|
sqlite_connect |
(config_json: StringHeader*) -> Promise* |
sqlite_disconnect |
(handle: i64) -> Promise* |
sqlite_execute |
(handle: i64, query_json: StringHeader*) -> Promise* |
sqlite_transaction_begin |
(handle: i64) -> Promise* |
sqlite_transaction_end |
(tx_handle: i64, options_json: StringHeader*) -> Promise* |
# Host check
cd native && cargo check
# iOS cross-compile check
cd native && cargo check --target aarch64-apple-ios
# Perry check (from package root)
perry check- Adding a new query operation: Add handler in
execute_querymatch, implement async fn taking&SqlitePool - Changing SQL dialect: All SQL generation is in
build_where,build_order_by,build_select_cols, and the operation functions — grep forformat!with SQL strings - Syncing with perry-prisma: Diff
native/src/lib.rsagainst perry-prisma's version; apply non-dialect changes