3manuek / sqlite_fdw

Foreign Data Wrapper for sqlite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sqlite_fdw

Foreign Data Wrapper for sqlite

Compilation

To use this FDW, you first need to compile it. You'll need pg_config and the usual build toolset. Then just launch:

make
make install

And you're good to go.

Adding the extension

Connect to your database, and execute this query:

CREATE EXTENSION sqlite_fdw;

Using it

You first need to add a server. It will have an option, the sqlite file path. It must be readable by the postgres process.

CREATE SERVER sqlite_server
  FOREIGN DATA WRAPPER sqlite_fdw
  OPTIONS (database '/var/lib/pgsql/test.db');

Then you can create your foreign table. It will have one option, the table name on the sqlite database:

CREATE FOREIGN TABLE local_t1(... columns ...)
  SERVER sqlite_server
  OPTIONS (table 'remote_table');

Now, to get the contents of the remote table, you just need to execute a SELECT query on it:

SELECT * FROM local_t1;

About

Foreign Data Wrapper for sqlite

License:Other


Languages

Language:C 96.0%Language:Makefile 4.0%