Current Status (
v15.0.0): This file preserves the original pre-wire-in architectural design note. The wire-in is long complete: all 96 AWS services and multi-cloud stores run on SQLAlchemy Core, and 12 RDBMS backends (SQLite, DuckDB, PostgreSQL 16.15, MySQL 8.4, MariaDB 11.4, Dolt, CockroachDB, Firebird 4.0, MSSQL 2022, Oracle Free 23, IBM Db2 12.1.6, and SAP HANA 2.0 SPS08) are live-verified end to end. Seedocs/DATABASES.mdfor current backend rules and live matrices.
Status at time of writing: dynamodb/database.py is implemented and unit-verified. The storage engine still uses the SQLite DBAPI directly; wiring it to Database is what makes the "runs on any RDBMS" claim true end to end.
What database.py provides
| Piece | Purpose |
|---|---|
Database(url) | One engine + connection for any SQLAlchemy URL |
Database.execute(sql, params) | DBAPI-shaped; rewrites ? → :pN quote-aware |
Database.execute_many | same, batched |
Database.transaction() | commit on success, rollback on raise |
Database.upsert_sql(table) | native upsert for SQLite / PostgreSQL / MySQL / MariaDB |
upsert(db, table, values) | portable; UPDATE-then-INSERT fallback for Oracle / SQL Server / Databricks |
metadata_obj | table definitions, so DDL is dialect-generated |
url_from_path(path) | maps the engine's historical db_path onto a URL |
Dialect-specific tuning lives in Database._setup_dialect: WAL, busy timeout and foreign keys are applied only to SQLite.
Wire-in steps (dynamodb/storage_engine.py)
- Constructor. Replace
self.conn = sqlite3.connect(db_path, ...) with self.db = Database(url_from_path(db_path)). Keep self.conn = self.db so the 26 with contextlib.closing(conn.cursor()) sites keep working — Database has no cursor(), so either:
- add
Database.cursor()returning an object withexecute/fetchone/
fetchall/close that delegates to Database.execute, or
- mechanical rewrite of the 26 sites to
self.db.execute(...).
Prefer the cursor() shim: it keeps the diff reviewable and leaves the query text untouched.
- PRAGMAs. Delete every
PRAGMA/VACUUM/ pool-read block from the
constructor (lines ~131-420). They are SQLite tuning and now belong to _setup_dialect. Keep the self.lock write lock — it is the engine's own serialisation and every dialect needs it.
- Read pool. Delete
_read_conns/_read_avail/_borrow_read/
keep-fresh / _wal_truncate machinery. Server engines pool internally; SQLite's WAL is handled by the dialect. _borrow_read() becomes a context manager yielding self.db under self.lock.
- Upserts. Replace the 4
INSERT OR REPLACE INTO(items ~1017, ~1153,
~1578, ~1846, ~1883) and 1 INSERT OR IGNORE INTO (tables_meta ~725) with upsert(self.db, <table>, {...}) / a duplicate check for the IGNORE case. Real AWS CreateTable on an existing table is already rejected explicitly above the insert, so the IGNORE can become an explicit existence check.
- Schema. Delete
_SCHEMA_TABLES_META/_SCHEMA_ITEMS/
_SCHEMA_GSI_INDEX and the CREATE INDEX block; metadata_obj.create_all in Database.__init__ replaces them.
begins_with. TheLIKEconstruction is dialect-fine but must escape
% and _ (also an AWS-correctness fix): build LIKE ? ESCAPE '\' and escape the prefix.
- Substring/
contains(if added).LIKE '%x%'is portable; Postgres has
ILIKE but DynamoDB contains is case-sensitive, so plain LIKE is right.
Testing the portability claim
- Run the full DynamoDB suite on
sqlite://(default) — this is the baseline
and must stay green.
- Add
tests/test_storage_backends.py, parametrised on
OFFSTACK_TEST_DATABASE_URLS (comma-separated). With none set, it runs the SQLite case only. With a Postgres URL it runs the same CRUD/Query/Scan/ BatchWrite/Transact assertions against that database. This is how a contributor verifies a new dialect without a CI matrix.
- The Databricks and Oracle cases cannot be CI-tested offline; document them as
"verified by dialect handling, unverified against a live instance".
Known per-dialect caveats
| Engine | Caveat |
|---|---|
| SQLite | Single writer; WAL only helps readers. The engine's write lock is doing the real work. |
| PostgreSQL | TEXT keys are fine; no varchar limit issues. Epoch-millisecond columns must be BigInteger — INTEGER is 32-bit and overflows. |
| MySQL/MariaDB | Verified 2026-11-10 against MySQL 8.4. Five schema rules apply, all detailed in DATABASES.md: key columns carry an explicit width (never TEXT), every index must fit InnoDB's 3072-byte budget, LogGroupName columns declare the ascii charset, every service MetaData is registered with mark_binary_collation() because MySQL's default collation is case-insensitive and DynamoDB keys are not, and binary payloads declare package_binary() because LargeBinary renders as a 65,535-byte BLOB that cannot hold a Lambda package. |
| Oracle | Empty string is NULL; sk default '' must become a sentinel or a nullable-with-coalesce column. Least-effort fix: store ''-keys as a single space or a sentinel string in the engine, consistently. |
| SQL Server | No UPDATE ... FROM needed here; the TOP rewrite in limit_clause covers the one pagination site. |
| Databricks | No multi-statement transactions on older runtimes; TransactWriteItems atomicity cannot be honoured. Document as read/write-compatible, not transaction-compatible. |
SQLite, PostgreSQL and MySQL/MariaDB are verified end to end — every service boots, creates its tables and answers a round-trip on each. Oracle, SQL Server and Databricks remain best-effort: their dialect handling exists and upsert_sql raises NotImplementedError so upsert() takes the portable path, but none has been run against a live server.
Want a live walkthrough or evaluation setup for Offstack? Message George Vranjesevic or reach out at george@developmentsnapshot.com.