Question

I am having a problem in date format conversion while I am exporting data from MySQL to CSV. I am using scriptelaa.1.1, the latest one I guess.

Here is my etl.properties file:

driver=mysql
url=jdbc:mysql://localhost:3306/<my_DB_name>
user=<user_name>
password=<password>
classpath=/path/to/mysql-connector-java-5.1.19.jar;

here is my etl.xml file:

<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
    <description>Scriptella ETL File Template.</description>
    <properties>
        <include href="/path/to/etl.properties"/> <!--Load from external properties file-->
    </properties>
<!-- Connection declarations -->
<connection id="in" driver="${driver}" url="${url}" user="${user}" password="${password}" classpath="$classpath">
</connection>
<connection id="out" driver="csv" url="report.csv">
    #Use empty quote to turn off quoting
    quote=
    null_string=\\N
    format.dob.type=date
    format.dob.pattern=yyyy-MM-dd HH:mm:ss
</connection>
<query connection-id="in">
    SELECT * FROM test;
<script connection-id="out">
    $1,$2,$3,$4
    </script>
 </query>    
</etl>

dob is my column name in MySQL table, it is datetime type column there. Now when I export the data from MySQL the time comes in the format yyyy-MM-dd HH:mm:ss.S But I want yyyy-MM-dd HH:mm:ss, so I have used

format.dob.type=date
format.dob.pattern=yyyy-MM-dd HH:mm:ss

As it is suggested scriptella.1.1 has the feature and to use it, in the following link: http://scriptella.javaforge.com/reference/index.html

But it is not working. Can anyone help me out.

Thanks. :)

Était-ce utile?

La solution

Formatting rules are applied to the variable name, therefore exactly the same variable name should be used for both format description and the expansion placeholder. In your cause, try using $dob instead of the column number.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top