Surgex v2.2.1 Surgex.DataPipe.TableSync

Extracts and transforms data from one PostgreSQL table into another.

Usage

Refer to Surgex.DataPipe for a complete data pipe example.

Summary

Functions

Synchronizes the given repository’s table with data fetched using a specified query

Functions

call(repo, source, target, opts \\ [])

Synchronizes the given repository’s table with data fetched using a specified query.

The synchronization is done via a single SQL query by utilizing the WITH statement. It first executes INSERT .. ON CONFLICT (called “upserting”) to insert and update new rows, followed by DELETE .. WHERE that removes old entries that didn’t appear in the input query.

Returns a tuple with a number of upserts (inserts + updates) and a number of deletions.