Configure TDSQL for MySQL Reader
The TDSQL for MySQL Reader component reads data from a TDSQL for MySQL data source. To synchronize data from a TDSQL for MySQL data source to another data source, you must first configure the TDSQL for MySQL Reader component and then configure the destination data source.
Prerequisites
-
A TDSQL for MySQL data source has been created. For more information, see Create a TDSQL for MySQL data source.
-
The account used to configure the TDSQL for MySQL Reader component properties must have the sync read permission for the data source. If you do not have this permission, you must apply for it. For more information, see Apply for permissions on a data source.
Procedure
-
On the top navigation bar of the Dataphin homepage, choose Develop > Data Integration.
-
On the top navigation bar of the Data Integration page, select a project. In Dev-Prod mode, you must also select an environment.
-
In the left-side navigation pane, click Batch integration. In the Batch integration list, click the batch pipeline that you want to develop.
-
In the upper-right corner of the page, click Component library to open the Component library panel.
-
In the left-side navigation pane of the Component library panel, select Input. From the component list on the right, find and drag the TDSQL for MySQL component to the canvas.
-
On the TDSQL for MySQL Reader component card, click the
icon to open the TDSQL for MySQL Input Configuration dialog box. -
In the TDSQL for MySQL Input Configuration dialog box, configure the parameters.
Parameter
Description
Step name
The name of the component. Dataphin generates a default name, which you can customize for your business scenario. The name must adhere to the following conventions:
-
The name can contain only Chinese characters, letters, underscores (_), and digits.
-
The name cannot exceed 64 characters in length.
Number of source tables
Select the number of source tables. Options include Single Table and Multiple Tables.
-
Single Table: Use this mode to synchronize data from a single source table to a single destination table.
-
Multiple Tables: Use this mode to synchronize data from multiple tables to a single destination table. Dataphin uses a UNION algorithm to write data from multiple tables to a single destination table.
For more information about the UNION operation, see INTERSECT, UNION, and EXCEPT.
Data source
The drop-down list shows all TDSQL for MySQL data sources in the current Dataphin project, regardless of whether you have the
sync read permission. If Number of source tables is set to Single Table, you can select only one data source. Click the
icon to copy the name of the current data source. If Multiple Tables is selected, you can select multiple data sources that are in the same time zone.-
If you lack the
sync read permissionfor a data source, click Apply next to it to request the permission. For more information, see Apply for permissions on a data source. -
If you do not have a TDSQL for MySQL data source, you can click Create Data Source in the drop-down list to create one. For more information, see Create a TDSQL for MySQL data source.
Database (Optional)
Select the database that contains the source table(s). If you leave this parameter empty, Dataphin uses the database specified during data source registration.
If you select Multiple Tables, you can select multiple databases. Click the
icon to view all selected databases in the Database List dialog box.Table matching mode
You can select general pattern or database regular expression.
NoteThis parameter is available only when you select Multiple Tables for Number of source tables.
Table
Select the source table(s).
-
If you select Single Table for Number of source tables, you can enter a keyword to search for the table, or enter the exact table name and click Exact Search. After you select a table, the system automatically checks the table status. Click the
icon to copy the name of the selected table. -
If you select Multiple Tables for Number of source tables, you can enter expressions to match tables based on the selected
table matching mode.-
When the table matching mode is set to general pattern, you can enter a table expression in the input box to filter for tables with the same structure. The system supports enumeration, regex-like patterns, and a combination of both. For example,
table_[001-100];table_102;table_abc*. The*wildcard is effective only at the beginning or end of a pattern. -
If you select database regular expression as the table matching mode, enter a regular expression supported by the current database. The system matches tables in the target database based on this expression. When the task runs, it dynamically discovers and synchronizes any new tables that match the expression.
After you enter the expression, you can click Exact Search to view a list of matched tables in the Confirm Matching Details dialog box.
-
Split key (Optional)
The system splits the data into partitions based on the configured split key. This allows for parallel data reading when used with the concurrency setting. For optimal performance, use the primary key or an indexed column as the
split key.ImportantIf you select a date or time column, the system identifies the minimum and maximum values and splits the data based on the total time range and the concurrency setting. The data may not be split evenly across partitions.
Input filter (Optional)
Specify a filter condition (a
WHEREclause without theWHEREkeyword) to extract specific data. Examples:-
Fixed value: Extracts a specific set of data. Example:
ds=20211111. -
Variable parameter: Extracts a portion of the data. Example:
ds=${bizdate}.
Output fields
This section displays all fields from the selected source tables. You can perform the following operations:
-
Field management: You can adjust the output fields in the Field management dialog box.
-
To delete individual fields: To remove a small number of fields, click the
icon in the Actions column for each field you want to delete. -
To delete fields in batches: To remove a large number of fields, click Field management. In the Field management dialog box, select the fields to remove and click the left arrow icon
to deselect them, and then click OK.
-
-
Batch Add: Click Batch Add to configure fields in batches by using JSON, TEXT, or DDL format.
NoteAfter you click OK, the batch add operation overwrites any existing field configurations.
-
To add fields in JSON format, use the following structure:
// Example: [{ "index": 1, "name": "id", "type": "int(10)", "mapType": "Long", "comment": "comment1" }, { "index": 2, "name": "user_name", "type": "varchar(255)", "mapType": "String", "comment": "comment2" }]NoteIn this example,
indexspecifies the 1-based column number in the source.nameandtypespecify the name and data type of the field after it is imported. For example,"index":3,"name":"user_id","type":"String"imports the third column from the source file, names the fielduser_id, and sets its data type toString. -
To add fields in TEXT format, use the following structure:
// Example: 1,id,int(10),Long,comment1 2,user_name,varchar(255),Long,comment2-
The row delimiter separates the information for each field. The default is a newline character (\n). Semicolons (;) and periods (.) are also supported.
-
The column separator is used to separate field names and field types. The default is a comma (,), and it supports
','. The field type can be omitted, and the default is','.
-
-
To add fields in DDL format, use the following structure:
CREATE TABLE tablename ( user_id serial, username VARCHAR(50), password VARCHAR(50), email VARCHAR (255), created_on TIMESTAMP, );
-
-
New Output Field: Click New Output Field and specify the Field, Type, and Comment, and select a Mapping type. After you configure the row, click the
icon to save it.System fields: You can select system fields to identify the source of each row of data. This is useful when you synchronize data from multiple tables (such as sharded databases and tables) to a single destination table. After you select a system field, Dataphin automatically populates its data type and mapping type. System fields include:
-
dp_datasource: The name of the data source to synchronize. -
dp_dbname: The name of the database to synchronize (if any). -
dp_schema: The name of the schema to synchronize (if any). -
dp_source_table: The name of the source table to synchronize. -
dp_read_timestamp: The start time of the SELECT statement at the source.
System fields support concatenating multiple system variables, for example,
dp_dbname.dp_source_table.Note-
The data type and mapping type of system fields cannot be modified.
-
dp_read_timestampmust be configured individually and cannot be concatenated.
-
-
-
Click OK to save the configurations for the TDSQL for MySQL Reader component.

icon to save it.