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.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# 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.
|
||||
Reference in New Issue
Block a user