Postgres Materialized View Dependency Manager
Project description
Description
pg_materialize is a utility for generating PostgreSQL creation and refresh scripts from a folder of Materialized View SQL definitions. It uses psqlparse to transform the SQL into parse trees, identifies which Materialized Views have a dependency on other views by generating a DAG, and produces the correct order for constructing and refreshing these views. Cross-schema views are handled correctly, and extraneous transaction blocks are filtered out from the final output. The files from each subsequent run are timestamped with the suffix YYYYMMDD-HHMMSS.sql.
Options
pg_materialize accepts the following command line arguments.
Analyzes dependencies without actually generating the output files.
The directory for the PostgreSQL scripts to analyze.
Regex pattern to match when ignoring refresh on Materialized Views (i.e. “hist” for “users_mv_hist”).
The directory for the output creation and refresh scripts.
Materialized View regex pattern to match (i.e. “_mv” for “users_mv”),
Enables verbose logging.
Example
Command:
pg_materialize -v \
-i ~/Projects/my_project/src \
-I hist \
-o ~/Projects/my_project/output
Output:
Found 97 Scripts in /Users/ali/Projects/my_project/src
Identified 169 Materialized Views, Containing 90 View Dependencies
Materialized View Dependencies:
'public.users_mv': ['public.user_addresses_mv',
'public.user_invites_mv'],
'public.orders_mv': ['public.payment_methods_mv']
Selecting 97 Materialized Views for Refresh
Successfully Saved Creation Script to ~/Projects/my_project/output/create-20170824-120626.sql
Successfully Saved Refresh Script to ~/Projects/my_project/output/refresh-20170824-120626.sql
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pg_materialize-0.2.5-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07abf36f3c29ee9812904f8f013b002966303734f96b59edb2b691e5198756c8 |
|
MD5 | f06315eb4efc8e6a24b029f5c48fba37 |
|
BLAKE2b-256 | 8eb5f55c2b6388d52d77a38f921fcc411de35814d99334e33a47f851f23b27ce |