Activating the template
In the data app templates, select ‘union connection data’, open and and run the app:Data App
The data app has 4 main blocks:- Start: database connections and helper functions. The critical one is ‘generate_sql_union’ that is responsible for the actual SQL creation.
- Select Connection: Streamlit component to show the connection type, connection and table selection.
- Create Union Tables: script to generate a union query per table and save/update it as Peliqan query and view.
- Refresh data: Refreshes the query definitions and schemas in Peliqan.
- Each union table will have an additional field ‘source’ showing the source name. By default this is the connection name, but you can alter this in the ‘get_source_name’ function. As example you will find for PowerOffice connections that the legalname is used.
- We will ensure all sources have the same columns and add a ‘null’ column if needed. Also data types will be cast to ensure a correct union statement.
- Add for ‘id’, ‘code’ and ‘no’ column pk and fk fields containing the source_name and the key. This is useful when the source system uses readable Id’s as this implies multiple records with the same id can be found in the union result table.
