Scenario 1: Writing columns from a MySQL database to an output file - 6.3

Talend Open Studio for Big Data Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Open Studio for Big Data
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

In this scenario we will read certain columns from a MySQL database, and then write them to a table in a local output file.

Dragging and dropping components and linking them together

  1. Drop tMysqlInput and tFileOutputDelimited from the Palette onto the workspace.

  2. Link tMysqlInput to tFileOutputDelimited using a Row > Main connection.

Configuring the components

  1. Double-click tMysqlInput to open its Basic Settings view in the Component tab.

  2. 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.

  3. Set the Schema as Built-in and click Edit schema to define the desired schema.

    The schema editor opens:

  4. 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.

  5. 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:

  6. Click the table of interest and then click OK to close the dialog box.

  7. Set the Query Type as Built-In.

  8. In the Query box, enter the query required to retrieve the desired columns from the table.

  9. Double-click tFileOutputDelimited to set its Basic settings in the Component tab.

  10. 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.

  11. Save the Job.

Executing the Job

The results below can be found after F6 is pressed to run the Job.

As shown above, the output file is written with the desired column names and corresponding data, retrieved from the database:

Note

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.