Tuesday, 29 January 2013

Talend: Reading data from mysql table in talend and writing it to a delimited flatfile

Reading data from mysql table in talend and writing it flatfile

  1. We need to identify table we need to read.
  2. Drop tmysqlinput component and enter your db credentials
  3. Write the “select * from sakila.city” in the sql query section of component.
  4. Now click on Guess Schema to get schema of the table.

  1. Next drag tfileoutputdelimited component from pallet on to your job (assuming we will create a delimited flatfile)
  2. now right click on tmysqlinput and select row and link it to tfileoutputdelimited
  3. next click on sync column properties in tfileoutputdelimited component to get schema of input row.

  1. Specify path for output file
  2. Now your job is almost ready - but you see small Warning symbol on both the component - this is because our table has a date column and it is preferred to have a date format specified against this column in schema definition
  3. click on schema of tmysqlinput and specify date pattern as "dd-MM-yyyy"
 click Yes on propogate changes dialog box.
and run the JOB it should finish successfully.
Try to play with file options of tfileoutputdelimited as below and see the impact on content of file generated

No comments:

Post a Comment