Wednesday, April 15, 2015

How to Insert Data from CSV Input File to Database

Firstly you have to drag and drop the connection which you have made for example my_db to design work space.



Then select tMysqlConnection component and click OK button.


Now here your connection has been dropped.


Now drag and drop Metadata > File Delimited > Student_CSV on design workspace.


Select tFileInputDelimited component and click OK button.


Now in design worksapce both the components are dropped
Right Click on my connection component select Trigger > OnSubjobOk and drag the line to the Student File Input Delimited.

 Drag and drop tmap component from Palette.
Right click on Student input file select Row > Main and drag a line to the tmap


Drag and drop tMysqlOuput on design workspace.
Right click on tmap and select Row > *New Output* (Main) and drag a line to tMysqlOuput.


This pop up window appears and fill the field as output.


 Double click on tmap component.Screen appear like this.



Now from row1 coloumn select student_id and press ctrl key and select student_name,student_branchid and drag and drop all to output coloumn.And click Apply button then click OK.


Now this window shows you want to propogate changes click Yes button.



 Now double click on tMysqlOutput on Basic Settings click checkbox Use an existing connection so that you don't have to connect to the database connection once again.Write the table name as student and on Action on table list select Create Table so that your table can be created in the database or you can select another options create table if does not exit based on your requirement.
On Action on data select Insert so data will be inserted into the database or you can select other option update or delete based on your requirement.


At last Run the execution  your data will be inserted in your database.


No comments:

Post a Comment