How to produce daily database table dumps in CSV format
file name pattern based on a current day. The produced files have the following naming format:
TABLE_NAME_MM_DD_YYYY.csv
1 2 <!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd"> 3 <etl> 4 <properties> <!-- Configure table name --> 5 table_name=test 6 </properties> 7 <connection id="in" driver="auto" url="jdbc:oracle:thin:@localhost:1521:ORCL" 8 classpath="ojdbc14.jar" user="scott" password="tiger"/> 9 <connection id="out" driver="csv" url="${table_name}_${etl.date.now('MM_dd_yyyy')}.csv" /> 10 <query connection-id="in"> <!-- Query table rows --> 11 SELECT * FROM ${table_name} 12 <script connection-id="out"> <!-- Export each row into a CSV --> 13 $ID, $Name, $Surname <!-- Use column names from selected table --> 14 </script> 15 </query> 16 </etl>
Use Scriptella ETL to run the example.
See How to execute an ETL file from command line, Ant or directly from Java .