In this scenario we will read certain columns from a MySQL database, and then write them to a table in a local output file.
Drop tAmazonMysqlInput and tFileOutputDelimited from the Palette onto the workspace.
Link tAmazonMysqlInput to tFileOutputDelimited using a Row > Main connection.
Double-click tAmazonMysqlInput to open its Basic Settings view in the Component tab.
From the Property Type list, select Repository if you have already stored the connection to database in the Metadata node of the Repository tree view. The property fields that follow are automatically filled in.
For more information about how to store a database connection, see Talend Studio User Guide.
If you have not defined the database connection locally in the Repository, fill in the details manually after selecting Built-in from the Property Type list.
Set the Schema as Built-in and click Edit schema to define the desired schema.
The schema editor opens:
Click the [+] button to add the rows that you will use to define the schema, four columns in this example id, first_name, city and salary.
Under Column, click in the fields to enter the corresponding column names.
Click the field under Type to define the type of data. Click OK to close the schema editor.
Next to the Table Name field, click the [...] button to select the database table of interest.
A dialog box displays a tree diagram of all the tables in the selected database:
Click the table of interest and then click OK to close the dialog box.
Set the Query Type to Built-In. In the Query box, enter the query required to retrieve the desired columns from the table.
Double-click tFileOutputDelimited to set its Basic Settings in the Component tab.
Next to the File Name field, click the [...] button to browse your directory to where you want to save the output file, then enter a name for the file.
Select the Include Header check box to retrieve the column names as well as the data.
Save the Job and press F6 to run it.
The output file is written with the desired column names and corresponding data, retrieved from the database:
The Job can also be run in the Traces Debug mode, which allows you to view the rows as they are being written to the output file, in the workspace.