# SQLite -> PostgreSQL virtual table (minimal) This directory contains a minimal SQLite extension that implements a read-only virtual table backed directly by PostgreSQL using libpq. Build ----- You need `libpq` (Postgres client) and a C compiler. On Debian/Ubuntu: ```bash sudo apt-get install libpq-dev build-essential make ``` This produces `pg_vtab.so`. Usage ----- Start `sqlite3`, load the extension and create a virtual table pointing at a Postgres table: ```sql .load ./pg_vtab.so CREATE VIRTUAL TABLE remote_tbl USING pg_vtab('host=localhost dbname=mydb user=me password=secret', 'public.mytable'); SELECT * FROM remote_tbl LIMIT 10; ``` Limitations ----------- - Minimal proof-of-concept: supports only full table scans. - All columns are presented as `TEXT`. - No constraint pushdown or type mapping sophistication. - Error handling and SQL injection hygiene are minimal; do not use on untrusted inputs without review. Next steps (optional) --------------------- - Add support for WHERE constraints and indexed access (`xBestIndex`). - Map Postgres types more accurately to SQLite storage classes. - Implement server-side cursors for large tables. - Harden error reporting and resource cleanup.