I'm trying to read .csv file from local directory and insert values into Mysql database. Please suggest me any example using Mulesoft.
Asked
Active
Viewed 3,075 times
0
-
Sorry, am new for this mulesoft am trying to do example with database insertion using file. – Narendar Apr 29 '14 at 11:47
3 Answers
1
Inserting CSV into a db:
How to read CSV file and insert data into PostgreSQL using Mule ESB, Mule Studio
Configuring MySQL:
http://blogs.mulesoft.org/working-with-databases-jdbc-in-mule-studio/
If you are reading the file in the middle of a flow, you can use the Requester Module with mulerequester:request
instead, like in this example:

Community
- 1
- 1

Anton Kupias
- 3,945
- 3
- 16
- 20
0
I've tried to implement this scenario. But ended up with something else. See if it is helpful to you.
<flow name="WriteToDB">
<file:inbound-endpoint path="${file_path}" moveToPattern="#[StringUtils.substringBeforeLast(message.inboundProperties.originalFilename,".txt")].bkp" moveToDirectory="${file_path}" connector-ref="FileRead" pollingFrequency="30000" responseTimeout="10000" doc:name="File">
<file:filename-regex-filter pattern=".*\.txt$" caseSensitive="true"/>
</file:inbound-endpoint>
<object-to-string-transformer doc:name="Object to String"/>
<logger message="Starting Split--------#[StringUtils.substringBeforeLast(message.inboundProperties.originalFilename,".txt")].bkp ----#[message.inboundProperties.originalFilename]" level="INFO" doc:name="Logger"/>
<splitter expression="#[StringUtils.split(message.payload, '\n\r')]" doc:name="Splitter"/>
<expression-component doc:name="Expression"><![CDATA[#[StringUtils.split(message.payload, '\n\r')]]]></expression-component>
<logger message="Split done #[message.payload]" level="INFO" doc:name="Logger"/>
</flow>

Ramu Chowdam
- 33
- 2
- 11
0
you use this flow
<flow name="apdev-americanFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/flights"
doc:name="HTTP"/>
<db:select config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[SELECT *
FROM american]]></db:parameterized-query>
</db:select>
<dw:transform-message doc:name="Transform Message"
metadata:id="6aa1324d-4ae4-4a42-9aeb-18da081f5cb1">
<dw:input-payload doc:sample="sample_data\list_map.dwl"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
payload map ((payload01 , indexOfPayload01) -> {
ID: payload01.ID,
code: payload01.code1 ++ payload01.code2,
price: payload01.price as :number,
departureDate: payload01.takeOffDate as :string,
destination: payload01.toAirport,
emptySeats: payload01.seatsAvailable as :number,
plane: {
type: payload01.planeType,
totalSeats: payload01.totalSeats as :number
}
})]]></dw:set-payload>
</dw:transform-message>
</flow>

Anil Agrawal
- 11
- 3