SQL to Hubspot Import
Last modified: 10 February 2025
This example show two Utility Blocks - SQL and Hubspot.
A Utility Block is a Ziggy plugin that typically wraps an NPM module or JS code but can really be anything at all.
You can find an in depth discussion about creating your own Utility Blocks in the Customisation topic.
Anyway, this Flow does the following.
Receiver
There's no data expected by the Receiver in this case. If this Flow was expected to perform a search, then the Receiver would expect the search parameters.
SQL
The first major action in the Flow
Connects to a Postgres database
using the Northwind Connection
reads all data from the customers table
and process it in batches of 20 records.
Batches
Batches are really important when processing large volumes of data that you cannot expect to hold in memory and where you want to write the data to some other API or database that cannot deal with huge chunks of data.
For an in depth discussion, please refer to the Batching topic.
Edge Mapping
You can see that this edge performs validation and edge mapping for the dataset. The Structures and Mapping topic goes into more detail on this.
The purpose of this mapping is to ensure that the data is converted into the right structure for upserting companies into Hubspot.
Hubspot
The Hubspot block upserts the data into Hubspot. The Hubspot API itself accepts and maximum of 100 records that can be upserted. This a perfect use case for the batching we used in the SQL Block.
We specify Batch Upsert as the Hubspot operation.
We point to the Ziggy Connection where the connection configuration (API Key) has been set up.
We specify the name of the Hubspot object we want to write to.
In this case, a special Hubspot property migration_uid has been created to identify the company by a unique field in the Northwind database. Therefore, we need to specify the name of this field so existence checking and updating can work.
Batch End
This makes it clear where the batch loop ends. When the Flow execution hits this Block, it knows to loop back to the starting point. If there is no more data available then it will continue onwards.