Create entities in bulk by importing a file
Selecting tables one by one in the Object browser is fine for a few entities. For a whole schema, import a file instead: a list of tables exported from the source database, an Excel sheet, or a YAML file with the settings of each entity. The Control Plane checks every table against the pipeline before anything is written, shows what it will create, lets you fix what is wrong, and saves the entities that are ready. This guide imports the tables of a SQL Server schema into PostgreSQL from a CSV export, adds a filtered entity from a YAML file, and compares the import with the Gluesync Automator.
In this guide
You will learn how to export the list of tables from the source catalog, how the import recognizes the columns of the file, how to choose a target schema for all the rows, how to read the results and the CREATE statements, how to fix a table without a primary key and leave out a system table, how to put the entities in groups and save them, what a second import of the same file does, what a YAML file adds, and when to use the Automator instead.
The steps were run on SQL Server 2022 as the source and PostgreSQL 16 as the target.
Quick information
Goal |
Create the entities of a whole schema from one file, check them and save them in the Control Plane |
Audience |
Data engineers and Gluesync administrators |
Level |
Beginner |
Time required |
About 20 minutes |
Area |
Control Plane → Pipelines → Entities → From tables → Import entities |
Applies to |
Gluesync 2.3 |
Before you begin
Make sure that:
-
Core Hub is 2.3.3 or later for CSV and Excel files. YAML and ZIP files can be imported from Core Hub 2.3.2;
-
A pipeline exists with its source and target connected. Here the source is SQL Server with CDC on every table: see MS SQL Server CDC source;
-
Your user has the
SUPER ADMINorMANAGERrole: importing creates entities. See User management and role-based access control.
Which file to use
| File | Use it when |
|---|---|
CSV, TSV, TXT or Excel |
You have a list of tables: a catalog export from the source database, or a sheet you fill in. It names the tables and, optionally, their target schema and table, entity name, group and keys. Columns, keys and types come from the database. |
YAML |
An entity needs more than a name: a filter, chosen columns, field functions, a second entity of the same table. This is the format the Automator reads and exports. |
ZIP |
The export of a pipeline from the Automator, with the code of its UDFs and Custom Field Functions. |
Guide steps
SQL
Run a query that lists the tables of the source schema and save the result as CSV. On SQL Server:
SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = 'dbo'
ORDER BY TABLE_NAME;
The sample schema dbo of the database shop gave:
TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE
dbo,customers,BASE TABLE
dbo,items,BASE TABLE
dbo,order_lines,BASE TABLE
dbo,orders,BASE TABLE
dbo,plants,BASE TABLE
dbo,price_list,BASE TABLE
dbo,stock_moves,BASE TABLE
dbo,systranschemas,BASE TABLE
systranschemas is not a business table: SQL Server creates it in dbo when CDC is enabled on the database. Keep the file as it is for now, to see what the import says about it.
Any tool that saves a query result as CSV or Excel works. The import also recognizes the catalog columns of Oracle, Db2, SAP HANA, PostgreSQL and the other sources: see How the columns are found.
UI
-
Open the pipeline, select Entities, then From tables. The page Listing database objects for database opens, with the Object browser;
-
Select Import entities in the page header.
The link Or import them from a file, under No entities selected, opens the same dialog.
The dialog Import entities from a file opens on its first step, Choose a file. It explains the two kinds of file and offers three templates under Start from a template: Excel workbook, CSV file and YAML file. Each one downloads a file with every column the import reads and example rows.
UI
-
Drag the CSV file onto the drop zone, or click it and choose the file. A CSV or Excel file opens the Columns step;
-
Check the columns found. Here Source schema is
A: TABLE_SCHEMAand Source table (required) isB: TABLE_NAME: the import recognized the catalog export, and leavesTABLE_TYPEout. To change them, select Edit the columns; -
Read the warning No target schema for some rows: the target has no schema named
dbo. In Default target schema, choosepublic. It applies to every row that names no target schema.
dbo schema.UI
-
Select Validate. The dialog says Nothing is changed while the file is validated. and shows its progress;
-
Read the chips above the rows: here Will create table: 6 and Error: 2. Create missing target tables (8) is on: the import creates the target tables when you save;
-
Expand a row with the arrow at its left. A Will create table row shows its CREATE statement, which you can copy;
-
Expand the two Error rows,
stock_movesandsystranschemas.
|
A |
The import listed systranschemas because the file names it: a table the file lists is imported even when its name starts with sys. Leave such tables out of the file.
UI
The export is a first draft. Complete it with the columns of the import: source_schema, source_table, target_schema, group and keys. Give stock_moves the columns that identify a row, separated by ;, and drop systranschemas:
source_schema,source_table,target_schema,group,keys
dbo,customers,public,master-data,
dbo,items,public,master-data,
dbo,plants,public,master-data,
dbo,price_list,public,master-data,
dbo,orders,public,orders,
dbo,order_lines,public,orders,
dbo,stock_moves,public,orders,move_ts;plant_code;item_id
-
Select the back arrow before the dialog title twice, to go back to Choose a file;
-
Choose the new file. The Columns step finds the five columns by their names, and no default target schema is needed;
-
Select Validate, then expand
stock_moves.
stock_moves gets its primary key from the keys column.UI + SQL
-
Select Add 7 entities to the selection. The dialog closes; the entities are on the page, not saved yet;
-
Read the banner: Imported from shop-entities.csv 7 entities are ready to save. An icon next to each entity opens its status and findings, and each entity shows its group. The groups the pipeline does not have yet are created when you save;
-
Select Confirm and continue.
The import does not start the entities. Select the start button of the Hold group, choose Full copy, and select Start entity. Here the seven entities became Active and the row counts on PostgreSQL matched the source. See Start a snapshot and CDC replication.
UI
Import a file again to add tables you left out, or after changing it. Here the same CSV was imported again.
UI + SQL
A CSV names tables. For a filter, chosen columns or a field function, use YAML. This file adds a second entity on dbo.orders: only the open orders, into a new table open_orders, with a column loaded_at filled when the row is written:
schemas:
dbo:
target: public
tables:
whitelist:
- orders
custom:
orders:
name: open_orders
entityName: Open orders
group: orders
filter:
clauses:
- {column: status, operation: Equal, value: open}
columns:
- {source: order_id, target: order_id}
- {source: customer_id, target: customer_id}
- {source: order_date, target: order_date}
- {source: status, target: status}
- {source: total, target: total}
- {target: loaded_at, targetDataType: timestamp(6), expression: {type: LocalTs}}
-
Import the file as in the steps above, and select Validate;
-
Expand the row Open orders.
Write each mapped column as {source: …, target: …}, and give a column that no source column feeds a targetDataType with its length or precision. The troubleshooting table lists what the import said for the other forms. Every key of the YAML format is in Entity import file reference.
Import in the Control Plane or use the Automator?
The Gluesync Automator reads the same YAML format. The two tools overlap on creating entities from a file, and differ on everything around it:
| Topic | Control Plane import | Gluesync Automator |
|---|---|---|
Where it runs |
In the Control Plane of Core Hub, in your browser. Nothing to install |
A separate program for Windows, macOS or Linux, with a web page on |
Files |
YAML, ZIP, and from Core Hub 2.3.3 CSV, TSV, TXT and Excel, with templates in the dialog |
YAML and ZIP. Its Bulk tab picks tables from the live source without a file |
What it creates |
New entities in the pipeline you are on, with their groups and target tables. From a ZIP, also their UDFs, compiled and linked when you save, and the pipeline’s Custom Field Functions, with Compile and publish. See Import a ZIP with UDFs and Custom Field Functions |
Entities, and from an archive whole pipelines with their agents, entities, schedules, UDFs and Custom Field Functions |
Before writing |
Checks every row against the pipeline and shows its status, its findings and the CREATE statement of each new table |
Preview shows the plan of each entity; Dry run goes through it without writing |
Fixing problems |
In the dialog: corrections under a row, Customize in Field mapping, or on the page before saving. The entities that are ready are saved; the others stay on the page |
In the file, or in the Customize panel of an archive (target names, passwords), then run again. Skip errors goes on past a failed entity |
Entities that exist |
Already exists, unticked. A second entity of the same table needs another name |
If the entity is already in the pipeline: keep, skip, update in place or fail |
Created tables |
Keep the source type when the target declares it, and MAX lengths |
Map each type to the target’s default type. See Differences from the Automator |
Schedules, unlocked schemas, custom write policies |
Not created, or the row is Unsupported |
Applied |
Export, backup, restore, duplicate |
Not available |
Available, with or without the agent passwords |
Who can use it |
Users with the |
Anyone who can run the program and sign in to Core Hub with a user that manages pipelines |
In short:
-
Use the Control Plane import to add tables to a pipeline you are working on: from a catalog export or a sheet, without installing anything, with each entity checked and the target tables shown before anything is written.
-
Use the Automator to move configuration: export and restore pipelines, copy them between Core Hubs, duplicate them with their agents, or create entities with schedules or settings the import does not support. See Use Gluesync Automator and Promote pipelines from QA to production.
-
Use both: export a pipeline with the Automator and import its YAML or ZIP in the Control Plane, to review every entity before it is created.
Troubleshooting
| Problem | Possible cause | What to do |
|---|---|---|
No target schema for some rows: |
The rows name no target schema, and the target has no schema with the source schema’s name |
Choose a Default target schema, or fill the |
Error: |
The table has no primary key and the row gives no |
Fill the |
A system table such as |
The file lists it: a listed table is imported even when its name starts with |
Remove its row from the file, or untick it |
Already exists on every row, and Add 0 entities to the selection |
The entities were already imported |
Nothing to do; to add a second entity of a table, tick its row and rename the entity |
|
A YAML with |
Write the mapped columns as |
|
A column that no source column feeds has no |
Add |
|
|
Write it with one, for example |