Model sync from MySQL to Snowflake
Set your Polytomic API key as an environment variable:
This example covers three steps:
- Create a MySQL Connection.
- Create a model over a MySQL table.
- Create a sync to Snowflake.
1. Create a MySQL connection
The following request creates a MySQL Connection. See the connection configuration reference for the required fields.
cURL
Python
Typescript
Go
2. Create a model
Next, create a model over the customers table on the MySQL Connection.
First, use the source endpoint to list the tables available on the Connection:
cURL
Python
Typescript
Go
The response will look like:
Sources
Drill into each level with query parameters — for example, ?table=company.accounts. In this case, requires_one_of on table is null, so no further drill-down is needed.
Now create a model over company.customers:
cURL
Python
Typescript
Go
Replace YOUR-CONNECTION-ID with the Connection ID returned in Step 1.
3. Create a sync
Next, create a sync from the customer model to a new Snowflake target.
Create a target Connection
Create a Snowflake Connection to use as the sync target:
cURL
Python
Typescript
Go
Enumerate the target
Targets enumerate the same way sources do:
cURL
Python
Typescript
Go
The response will look like:
Drill down recursively using the requires_one_of field. For example:
cURL
Python
Typescript
Go
The response will look like:
The schema level requires a table. Enumerate tables by adding another query parameter:
cURL
Python
Typescript
Go
The response will look like:
Query target fields
Finally, query the available fields on the target. POST to the fields endpoint for the target resource:
cURL
Python
Typescript
Go
The response lists the available sync modes and every field on the target along with its metadata. For example:
Create the sync
Map fields from the source model to the target and create the sync:
