0
我需要從MYSQL數據庫中提取數據並根據數據創建格式化文件。 Talend開放工作室如何做到這一點?如何在基於MySQL表的Talend open studio中生成多個格式文件?
MySQL DB有一個表(user_id,order_id,purchase_date),我需要爲每個用戶生成csv文件包含他的訂單。文件名應該有USER_ID(輸出文件也能像user_id.csv)
感謝
我需要從MYSQL數據庫中提取數據並根據數據創建格式化文件。 Talend開放工作室如何做到這一點?如何在基於MySQL表的Talend open studio中生成多個格式文件?
MySQL DB有一個表(user_id,order_id,purchase_date),我需要爲每個用戶生成csv文件包含他的訂單。文件名應該有USER_ID(輸出文件也能像user_id.csv)
感謝
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..
謝謝你..這是工作的罰款,我剛纔固定類似下面的語法: tmysqlInput( sql =「select user_id,order_id,purchase_date from table where user_id =」+ globalMap.get(「user_id」); –