Files
new_dbsync/README_pg_vtab.md
T
wjones a18c6a7386 Add PostgreSQL virtual table extension and SQLite utilities
- Implement pg_vtab as a minimal SQLite virtual table module backed by PostgreSQL.
- Create sqlite2pgsql utility for copying tables from SQLite to PostgreSQL.
- Add sqlite_pg_plugin to expose PostgreSQL tables to SQLite.
- Include Makefile for building the pg_vtab shared object.
- Update README with usage instructions and limitations.
- Remove obsolete cache.zip file.
2025-12-11 18:45:49 +00:00

1.2 KiB

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:

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:

.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.