我需要从MYSQL DB中提取数据并根据数据创建格式化文件。我怎么能通过Talend open studio做到这一点??
MySQL DB有一个表(user_id,order_id,purchase_date),我需要为每个用户生成csv文件包含他的订单。文件名应该有user_id(输出文件可以像user_id.csv)
由于
答案 0 :(得分:1)
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..