Skip to content

feat: add SQLite schema adapter#9

Open
wondr-wclabs wants to merge 1 commit into
Cyberfilo:mainfrom
wondr-wclabs:codex/sqlite-schema-adapter
Open

feat: add SQLite schema adapter#9
wondr-wclabs wants to merge 1 commit into
Cyberfilo:mainfrom
wondr-wclabs:codex/sqlite-schema-adapter

Conversation

@wondr-wclabs

Copy link
Copy Markdown

Summary

This adds the first database-adapter slice for #4: keep Postgres as the reference implementation, introduce backend selection by DSN, and add SQLite support without adding any new runtime dependency.

I intentionally kept MySQL out of this PR. SQLite is available through the Python standard library, so it exercises the adapter shape without forcing a driver decision. MySQL can now be added as a follow-up optional-extra implementation against the same Schema/Table/Column/ForeignKey model.

What changed

  • Add SQLiteDatabase and make_database() so sqlite:///local.db routes through a SQLite backend while existing Postgres DSNs keep the current Database path.
  • Open SQLite file-backed databases with mode=ro and also enable PRAGMA query_only = ON, preserving the two-layer read-only model used by Postgres.
  • Dispatch schema introspection by database dialect:
    • Postgres keeps the existing pg_catalog mapping.
    • SQLite reads tables/views from sqlite_schema, columns from PRAGMA table_xinfo, and foreign keys from PRAGMA foreign_key_list.
  • Pass the selected dialect into sqlglot validation instead of hard-coding Postgres.
  • Document SQLite usage and the current scope in README/ARCHITECTURE.

Validation

  • .venv/bin/python -m pytest tests/test_schema_adapters.py tests/test_safety.py -q -> 26 passed
  • .venv/bin/python -m pytest -q -> 55 passed
  • .venv/bin/python -m promptquery --help
  • git diff --check

@wondr-wclabs wondr-wclabs force-pushed the codex/sqlite-schema-adapter branch from 4350eb3 to d06ff16 Compare June 5, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant