Write to MySQL
This guide shows you how to create a MySQL Write Component.
Prerequisites​
- MySQL Connection with write permissions
- An Ascend Flow with a Component that contains data
Create a new Write Component​
From your workspace Super Graph view, follow these steps to create your Write Component:
- Form
- Files panel
- Double-click the Flow where you want to create your Component
- Right-click on any Component
- Hover over Create Downstream -> Write, and select your target Connection
- Complete the form with these details:
- Select your Flow
- Enter a descriptive Component Name like
write_mysql
- Open the Files panel in the top left corner
- Navigate to and select your desired Flow
- Right-click on the components directory and choose New file
- Name your file with a descriptive name like
write_mysql.yaml
and press enter
Configure your MySQL Write Component
Follow these steps to configure your MySQL Write Component:
- Set up your Connection
- Enter your MySQL Connection name in the
connection
field
- Enter your MySQL Connection name in the
- Define your data source
- Set
input
to the Component that contains your source data
- Set
- Configure the write destination
- Set up the
mysql
write connector options - Specify your target table name, schema, and other required properties
- Set up the
- Choose a write strategy
Select the strategy that best fits your use case:
Strategy Description Best for full (default)
Replaces the entire target table during each Flow Run Reference tables, complete data refreshes partitioned
Updates only the partitions that have changed Time-series data, regional datasets, date-partitioned tables snapshot
Creates flexible output as a single file or multiple chunks Data exports, analytical datasets, flexible output formats
For detailed guidance on when to use each strategy, see the write strategies guide.
Examples​
- Full write
- Incremental write
write_full_mysql.yaml
component:
write:
connection: write_mysql
input:
name: my_component
flow: my_flow
strategy:
full:
mode: drop_and_recreate
mysql:
table:
name: my_output_table
This configuration:
- References a MySQL Connection named
write_mysql
- Uses
my_component
frommy_flow
as the input data - Applies a full write strategy with drop_and_recreate mode
- Writes to a MySQL table named
my_output_table
write_incremental_mysql.yaml
component:
write:
connection: write_mysql
input:
name: my_component
flow: my_flow
strategy:
incremental_column: timestamp
incremental:
merge:
deletion_column: timestamp
unique_key: id
mysql:
table:
name: my_output_table
This configuration:
- References a MySQL Connection named
write_mysql
- Uses
my_component
frommy_flow
as the input data - Applies an incremental write strategy using the
timestamp
column - Uses merge mode with
id
as the unique key andtimestamp
as the deletion column - Writes to a MySQL table named
my_output_table
🎉 Congratulations! You successfully created a MySQL Write Component in Ascend.