The tMysqlOutputBulk and tMysqlBulkExec components are used together in a two step process. In
the first step, an output file is generated. In the second step, this file is used in
the INSERT statement used to feed a database. These two steps are fused together in the
tMysqlOutputBulkExec component, detailed in a
separate section. The advantage of using two separate steps is that the data can be
transformed before it is loaded in the database.
Component family |
Databases/MySQL |
|
Function |
Writes a file with columns based on the defined delimiter and the |
|
Purpose |
Prepares the file to be used as parameter in the INSERT query to |
|
Basic settings |
Property type |
Either Built-in or Since version 5.6, both the Built-In mode and the Repository mode are |
|
|
Built-in: No property data stored |
|
|
Repository: Select the repository |
|
File Name |
Name of the file to be generated. This file is generated on the same machine where the Studio is |
|
Append |
Select this check box to add the new rows at the end of the |
|
Schema and Edit |
A schema is a row description. It defines the number of fields to be processed and passed on Since version 5.6, both the Built-In mode and the Repository mode are |
|
|
Built-In: You create and store the schema locally for this |
|
|
Repository: You have already created the schema and When the schema to be reused has default values that are integers or functions, ensure that For more details, see https://help.talend.com/display/KB/Verifying+default+values+in+a+retrieved+schema. |
Click Edit schema to make changes to the schema. If the
|
||
Advanced settings |
Row separator |
String (ex: ” |
|
Field separator |
Character, string or regular expression to separate fields. |
|
Text enclosure |
Character used to enclose the text. |
|
Create directory if does not exist |
This check box is selected by default. It creates a directory to |
|
Custom the flush buffer size |
Customize the amount of memory used to temporarily store output |
|
Records contain NULL value |
This check box is selected by default. It allows you to take |
|
Check disk space |
Select the this check box to throw an exception during execution |
|
Encoding |
Select the encoding from the list or select Custom and define it manually. This field is |
|
tStatCatcher Statistics |
Select this check box to collect the log data at the component |
Global Variables |
NB_LINE: the number of rows processed. This is an After ERROR_MESSAGE: the error message generated by the A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see Talend Studio |
|
Usage |
This component is to be used along with tMySQlBulkExec component. Used together they offer |
|
Log4j |
The activity of this component can be logged using the log4j feature. For more information on this feature, see Talend Studio User For more information on the log4j logging levels, see the Apache documentation at http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html. |
|
Limitation |
Due to license incompatibility, one or more JARs required to use this component are not |
This scenario describes a four-component job which aims at fueling a database with
data contained in a file, including transformed data. Two steps are required in this
job, first step is to create the file, that will then be used in the second step. The
first step includes a tranformation phase of the data included in the file.
-
Drag and drop a tRowGenerator, a
tMap, a tMysqlOutputBulk as well as a tMysqlBulkExec component. -
Connect the main flow using row Main
links. -
And connect the start component (tRowgenerator in this example) to the tMysqlBulkExec using a trigger connection, of type OnComponentOk.
-
A tRowGenerator is used to generate
random data. Double-click on the tRowGenerator
component to launch the editor. -
Define the schema of the rows to be generated and the nature of data to
generate. In this example, the clients file to be
produced will contain the following columns: ID,
First Name, Last Name,
Address, City which all are
defined as string data but the ID that is of integer type.Some schema information don’t necessarily need to be displayed. To hide
them away, click on Columns list button
next to the toolbar, and uncheck the relevant entries, such as Precision or Parameters.Use the plus button to add as many columns to your schema
definition.Click the Refresh button to preview the first generated row of your
output. -
Then select the tMap component to set the
transformation. -
Drag and drop all columns from the input table to the output table.
-
Apply the transformation on the LastName column by
adding.toUpperCase()
in its expression field.Then, click OK to validate the
transformation. -
Double-click on the tMysqlOutputBulk
component. -
Define the name of the file to be produced in File
Name field. If the delimited file information is stored in
the Repository, select it in Property Type field, to retrieve relevant data.
In this use case the file name is clients.txt.The schema is propagated from the tMap
component, if you accepted it when prompted. -
In this example, don’t include the header information as the table should
already contain it. -
Click OK to validate the output.
-
Then double-click on the tMysqlBulkExec
component to set the INSERT query to be executed. -
Define the database connection details. We recommend you to store
this type of information in the Repository, so that you can retrieve them at any time
for any Job. -
Set the table to be filled in with the collected data, in the Table field.
-
Fill in the column delimiters in the Field
terminated by area. -
Make sure the encoding corresponds to the data encoding.
-
Press Ctrl+S to save your Job.
-
Press F6 or click Run on the Run tab to
execute the Job.The clients database table is filled with data from
the file including upper-case last name as transformed
in the job.
For simple Insert operations that don’t include any transformations, the use of
tMysqlOutputBulkExec allows you to skip a step
in the process and thus improves performance.
Related topic: tMysqlOutputBulkExec properties