I need to pull data from MYSQL DB and create formatted files depending on the data. How can I do that by Talend open studio??
MySQL DB has one table ( user_id, order_id, purchase_date) and I need to generate csv files for each user contains his orders. files names should have the user_id ( output files could be like user_id.csv)
Thanks
You can try below -
tMysqlInput--->tFlowToIterate---(iterate)-->tMysqlInput--->tFileOutputDelimited
More details given below -
tmysqlInput(select user_id from table group by user_id) --- row Main ---> tFlowToIterate (uncheck use the default key option, create a new key called user_id and set value to user_id in dropdown) ----- Iterate -----> tmysqlInput(sql = "select user_id, order_id,purchase_date from table where user_id=((String)globalMap.get("user_id))") ----- row main ----> tFileOutputDelimited(set filename = (String)globalMap.get("user_id))+".csv").
to summarize - you first get list of all distinct user_id then you iterate through each of them and again fetch orders for each user_id by applying filter and use this user_id value from global variable into filename..