Elyra
Elyra The coding agent eTerm The terminal that knows where each command ends Huskarl AI colleagues on your own Mac Starf An activity monitor for Apple silicon that never invents a number etrans An SSH and SFTP client for macOS Elyra VM Virtual machines for macOS, Linux and Windows on your Mac Litr A small, native web browser for macOS Notr A notebook for macOS e The native code editor Elyra Grove Native local development environment Askr The real server for Laravel & PHP Elyra Framework Rust + Svelte 5 framework for desktop apps Elyra Conductor Local project conductor Refr Local-first PDF workspace for macOS Elyra Workspace A desktop workspace for coding agents eDock A container runtime for the Mac Elyra SQL Server MySQL-compatible SQL server in Rust Elyra Félagi Agents as teammates on one board Elyra SQL Client Native desktop SQL workbench Elyra SQL Anywhere Replication-ready SQL engine Elyra Sjá SEO & GEO workspace for macOS Elyra DataGrid Server-driven data grid for Laravel
Reference
Ratatosk CLI
Roadmap
RFC 0001: make:resource
RFC 0002: live queries
RFC 0003: MCP server
RFC 0004: MCP resource templates
RFC 0005: a Laravel backend
RFC 0006: Laravel broadcasting
RFC 0007: offline and sync
RFC 0008: Laravel notifications
RFC 0009: Files
RFC 0010: Laravel abilities
RFC 0011: an assistant in the app
RFC 0012: @elyra/ui
RFC 0013: the assistant sees the window
RFC 0014: Elyra Inspector
RFC 0015: presence
RFC 0016: capabilities per window
RFC 0017: record invalidation
RFC 0018: the assistant's answer, streamed
RFC 0019: a window from the tray
RFC 0020: an app that stays in the tray
RFC 0021: a server chosen at sign-in
RFC 0022: signed in to more than one server
RFC 0023: private channels a window listens to
RFC 0024: updates from the backend
RFC 0025: commands and configuration
RFC 0026: the running app, for coding agents
RFC 0027: the assistant's code mode
RFC 0028: the tray's icon, and the app's
RFC 0029: installers
RFC 0030: the app's identity on Windows
RFC 0031: a token per workspace
RFC 0032: the microphone
RFC 0033: diagnostics the user can send
RFC 0034: one screen in several states at once
RFC 0035: point at it, and hand it to the agent
RFC 0036: rata check, the app checked as a whole
RFC 0037: Theme Studio
RFC 0038: edit it in its own app
RFC 0039: a write shown at once in every window
RFC 0040: the two halves agree
RFC 0041: Quick Look
RFC 0042: follow a colleague
RFC 0043: every write seen
RFC 0044: composite keys
RFC 0045: bigint all the way
RFC 0046: pivot columns
RFC 0047: relations on any key
RFC 0048: more providers
RFC 0049: OpenAI web search
RFC 0050: integer-keyed arguments
RFC 0051: citations
RFC 0052: open documents
RFC 0053: exit hooks
RFC 0054: the gui feature
RFC 0055: menus that change
RFC 0056: the framework's own words
RFC 0057: rata upgrade
RFC 0058: @elyra/charts
RFC 0059: all of WireCharts
RFC 0060: exporting a chart
RFC 0061: zoom
RFC 0062: printing
RFC 0063: linked charts
RFC 0064: report pages
RFC 0065: marks
RFC 0066: taking a table out
RFC 0067: totals
RFC 0068: columns the user picks
RFC 0069: filters
RFC 0070: saved views
RFC 0071: lists over Laravel
RFC 0072: targets
RFC 0073: every row out
RFC 0074: grouped rows
RFC 0075: pinned columns
RFC 0076: views on the server
RFC 0077: every match selected
RFC 0078: editing in the table
RFC 0079: many cells at once
RFC 0080: a value for the selected rows
RFC 0081: a new row in the table
RFC 0082: a related record in a cell
RFC 0083: a filter by a related record
RFC 0084: one write for many rows
RFC 0085: the keys shown
RFC 0086: many rows in Laravel
RFC 0087: many rows deleted
RFC 0088: the trash
Release notes
Changelog
Elyra

Database

Feature-gated behind database. One Database handle spans SQLite, MySQL, and Postgres via sqlx's Any driver — the backend is chosen by the URL scheme. It lives in the GUI-free elyra-db crate so the CLI can use it too.

elyra = { …, features = ["database"] }

Connecting

The easiest path is App::database, which connects lazily and binds a Database into the container:

App::new()
    .database("sqlite://app.db?mode=rwc")   // scheme picks the driver
    .commands(commands![list_todos]);
Scheme Driver
sqlite: SQLite
mysql: / mariadb: MySQL
postgres: / postgresql: Postgres

Resolve it in commands:

use elyra::{Database, Ctx};

#[command]
async fn count(ctx: Ctx) -> Result<i64, String> {
    let db = ctx.get::<Database>();
    let row = elyra::db::sqlx::query("SELECT COUNT(*) AS n FROM todos")
        .fetch_one(db.pool()).await.map_err(|e| e.to_string())?;
    Ok(elyra::db::sqlx::Row::try_get(&row, "n").map_err(|e| e.to_string())?)
}

API

  • Database::connect(url).await — connect eagerly (async; for the CLI / setup).
  • Database::connect_lazy(url) — build the pool without connecting; connections open on first use (sync; used by App::database).
  • db.pool() — the underlying sqlx::AnyPool, for running queries.
  • db.driver() — the detected Driver (Sqlite / MySql / Postgres).
  • db.migrator(dir) — a Migrator sharing this pool.

Writing queries

sqlx is re-exported as elyra::db::sqlx, so app crates don't need a direct dependency:

use elyra::db::sqlx::{self, Row};

Placeholders differ per backend (? for sqlite/mysql, $1 for postgres); the Any driver does not translate them. For hand-written queries, mind the target driver — or use models, whose query builder renders placeholders per driver for you.

Building a SQLite URL from a path

use elyra_db::sqlite_url;

let path = elyra::system::paths().data.map(|d| format!("{d}/myapp/app.db")).unwrap();
App::new().database(sqlite_url(&path))

format!("sqlite://{}", path.display()) is the obvious thing to write and is wrong on Windows: the drive colon and backslashes don't match the URL grammar, and SQLite answers unable to open database file. sqlite_url normalizes the separators and uses the three-slash absolute form; it appends ?mode=rwc so the file is created when missing (sqlite_url_opts(path, false) opts out).

Pool options

Defaults are deliberately desktop-shaped (a small pool and a bounded wait, not sqlx's unlimited acquire):

use elyra::db::{Database, DatabaseOptions};
use std::time::Duration;

let db = Database::connect_with(
    url,
    DatabaseOptions::default()
        .max_connections(8)
        .acquire_timeout(Duration::from_secs(5)),
).await?;
Option Default
max_connections 5
min_connections 0
acquire_timeout 10s
idle_timeout 10min
max_lifetime 30min

SQLite additionally gets journal_mode = WAL, busy_timeout = 5000 and foreign_keys = ON on connect, so the UI thread and background jobs can share the file.

Transactions

db.transaction(|tx| Box::pin(async move {
    sqlx::query("UPDATE accounts SET balance = balance - 100 WHERE id = 1")
        .execute(&mut **tx).await?;
    sqlx::query("UPDATE accounts SET balance = balance + 100 WHERE id = 2")
        .execute(&mut **tx).await?;
    Ok(())
})).await?;

Commits on Ok, rolls back on Err and returns your error. db.begin() gives you the raw sqlx::Transaction when you need manual control.

Changes

Every Database clone shares a change hub: each model-layer write reports its table once it's durable — the generated insert / update / delete / save, Query's bulk update / delete / soft_delete / restore (only when a row changed), factories, and the pivot operations (attach, detach, sync, which report the pivot table).

let mut changes = db.changes().subscribe();
tokio::spawn(async move {
    while let Ok(table) = changes.recv().await {
        // "customers", "role_user", … — or `Err(Lagged)`: assume everything changed
    }
});

Without capture, the model layer can't see raw SQL, so report it by hand — a table, or any other key you want to treat the same way:

sqlx::query("UPDATE orders SET status = 'shipped'").execute(db.pool()).await?;
db.touch("orders");
db.touch("settings:theme");

Inside transaction, reports are held and sent on commit; a rollback sends nothing. This is the data side of live queries (RFC 0002): elyra::db::live::track records the tables a piece of code reads, so it can be re-run when one of them changes.

Every write seen

With capture_changes(), the database itself says which tables changed, however they were changed: raw SQL, a migration, a sidecar, another process on the same file or server (RFC 0043).

App::new()
    .database(sqlite_url(&path))
    .capture_changes()

// or, on a Database of your own
let db = Database::connect(url).await?.capture_changes();
  • SQLite and MySQL: a trigger per table and operation (_elyra_<table>_insert, _update, _delete) bumps the table's row in _elyra_changes, and the app reads the counts every 250 ms (capture_changes_every(..), never under 50 ms). A count that moved is a table that changed.
  • Postgres: a statement trigger per table (_elyra_changes, calling _elyra_notify()) says the table with NOTIFY elyra_changes, and the app listens on a connection of its own. When that connection drops and comes back, every watched table is reported once.
  • Installed for every table there is when the database connects, again after each migration this Database runs (its migrator, the app's ELYRA_MIGRATE mode), and with db.watch_tables().await, for a table made later by raw SQL or another process. Not for the framework's own tables (_elyra_*, elyra_outbox, elyra_jobs, …).
  • The app's own model-layer writes are reported twice: at once, and by the trigger. The second re-run finds the same result, so nothing is pushed to the windows.
  • A rolled-back write says nothing: the trigger ran in its transaction.
  • TRUNCATE on MySQL fires no trigger; db.touch(..) after one.
  • db.capture_status() says what it's doing (the tables, the last look, the last error), and the inspector shows it under the live queries. db.unwatch_tables().await takes it all out again.

It changes the schema of the database it watches: on one another application owns (a server's MySQL the desktop app reads directly), that's your decision. Creating a trigger on MySQL with binary logging on may need the TRIGGER and SUPER privileges (or log_bin_trust_function_creators).

Testing status

SQLite is fully test-covered (including the query builder, pagination, joins, soft deletes and transactions). MySQL and Postgres run model CRUD against real servers in CI.

Related