Giter VIP home page Giter VIP logo

sqlite_fdw's Introduction

SQLite Foreign Data Wrapper for PostgreSQL

This PostgreSQL extension is a Foreign Data Wrapper for SQLite.

The current version can work with PostgreSQL 10, 11, 12, 13 and 14.

Installation

1. Install SQLite library

For debian or ubuntu:

apt-get install libsqlite3-dev

You can also download SQLite source code and build SQLite.

2. Build and install sqlite_fdw

Add a directory of pg_config to PATH and build and install sqlite_fdw.

make USE_PGXS=1
make install USE_PGXS=1

If you want to build sqlite_fdw in a source tree of PostgreSQL, use

make
make install

Usage

Load extension

CREATE EXTENSION sqlite_fdw;

Create server

Please specify SQLite database path using database option:

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

Create foreign table

Please specify table option if SQLite table name is different from foreign table name.

CREATE FOREIGN TABLE t1(a integer, b text) SERVER sqlite_server OPTIONS (table 't1_sqlite');

If you want to update tables, please add OPTIONS (key 'true') to a primary key or unique key like the following:

CREATE FOREIGN TABLE t1(a integer OPTIONS (key 'true'), b text) SERVER sqlite_server OPTIONS (table 't1_sqlite');

If you need to convert INT SQLite column (epoch Unix Time) to be treated/visualized as TIMESTAMP in PostgreSQL, please add OPTIONS (column_type 'INT') when defining FOREIGN table at PostgreSQL like the following:

CREATE FOREIGN TABLE t1(a integer, b text, c timestamp without time zone OPTIONS (column_type 'INT')) SERVER sqlite_server OPTIONS (table 't1_sqlite');

Import foreign schema

IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_server INTO public;

Access foreign table

SELECT * FROM t1;

Features

  • Support update to foreign table
  • WHERE clauses are pushdowned
  • Aggregate function are pushdowned
  • Order By is pushdowned
  • Joins (left/right/inner) are pushdowned
  • Limit and Offset are pushdowned (*when all tables queried are fdw)
  • Transactions
  • Support TRUNCATE by deparsing into DELETE statement without WHERE clause
  • Allow control over whether foreign servers keep connections open after transaction completion. This is controlled by keep_connections and defaults to on
  • Support list cached connections to foreign servers by using function sqlite_fdw_get_connections()
  • Support discard cached connections to foreign servers by using function sqlite_fdw_disconnect(), sqlite_fdw_disconnect_all().
  • Support Bulk Insert by using batch_size option
  • Support Insert/Update with generated column

Limitations

  • COPY command for foreign tables is not supported
  • IMPORT of generated column is not supported
  • Insert into a partitioned table which has foreign partitions is not supported
  • TRUNCATE in sqlite_fdw always delete data of both parent and child tables (no matter user inputs TRUNCATE table CASCADE or TRUNCATE table RESTRICT) if there are foreign-keys references with "ON DELETE CASCADE" clause.

Contributing

Opening issues and pull requests on GitHub are welcome.

License

Copyright (c) 2017 - 2021, TOSHIBA Corporation
Copyright (c) 2011 - 2016, EnterpriseDB Corporation

Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.

See the LICENSE file for full details.

sqlite_fdw's People

Contributors

mochizk avatar hrkuma avatar mlt avatar kanegoon avatar pruiz avatar kylelilly avatar tunghdt avatar dbuenor avatar theory avatar ibarwick avatar aka-sps avatar t-kataym avatar khieuvm avatar lamduongngoc avatar namnguyen1405 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.