Scriptella - Date format conversion not working - scriptella

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. :)

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.

Related

copy data using scriptella based on a test on special column

I have two databases in postgresql. I want to copy data from database to another based on a condition.I used scriptella but what i want is to copy rows when a column is not empty.But i always have the empty ones which are copied here what i did , i want to copy based on condition on a special column .
Here is the file
<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
<description>
test script
</description>
<connection id="in" driver="postgresql" url="jdbc:postgresql://localhost:5432/testMonoprix" user="postgres" password="maher" >
</connection>
<connection id="out" driver="postgresql" url="jdbc:postgresql://localhost:5432/testMonoprix2" user="postgres" password="maher">
</connection>
<query connection-id="in" >
SELECT * FROM public.param_type;
<script connection-id="out" if=" parent_param_type_id != null ">
INSERT INTO public.param_type VALUES (?1, ?2,?3,?4,?5,?6) ;
</script>
</query>
</etl>
How would the file be in order to copy non empty ones ,
Thanks

Adding today date/time value into excel file using ant

I'm using ant to get CSV files from an other ERP and send it into my SFDC system.
The batch will be every hour, so I used a script to move files to other dir each time a batch is finished
The issue that I want to rename those files to be the same name given but with date/time of NOW.
I found a rename script but I didn't managed to find any date time script to get the string value of date time - now
You can use <tstamp> to get the current date and time. Example:
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd" />
</tstamp>
<echo message="${TODAY}" />

Parse HTML stored as string in Database in ColdFusion

I have taken over this ColdFusion project and found that I need a value out of a database field that includes HTML. The field data looks like this (without the new lines):
<wddxPacket version="1.0">
<header />
<data>
<struct>
<var name="en">
<string>3 Nights' Lodging</string>
</var>
<var name="sp">
<string>3 Noches alojamiento</string>
</var>
</struct>
</data>
</wddxPacket>
I am wanting to use this data but I only need the text between the:
<var name='en'><string>3 Nights' Lodging</string></var>
I used a function that ColdFusion has to remove HTML:
#REReplaceNoCase(pkg.title, "<[^><]*>", '', 'ALL')#
But when I use that, I get something like this:
3 Nights' Lodging3 Noches alojamiento
All I want is:
3 Nights' Lodging
Examining the beginning of the string, ie <wddxPacket ...> it is actually WDDX.
If you do a search for ColdFusion + WDDX you will find the documentation for CFWDDX. It is a built in tag which supports conversions of WDDX strings to CFML objects (and vice versa) for easier manipulation. In your case use action="wddx2cfml" to convert the string back into a CF structure.
<cfwddx action="wddx2cfml" input="#text#" output="result">
<cfdump var="#result#" label="Raw object">
Then use the key #result.en# to grab the string you want.

date format configuration in dozer.xml

I am using Dozer mapper to map Service objects to Value objects. I am mapping the date by means of the following:
<mapping date-format="dd-MM-yyyy">
<class-a>MySo</class-a>
<class-b>MyVO</class-b>
<field>
<a>dateStr</a>
<b>dateObj</b>
</field>
</mapping>
However, I need to specify the format for the date each time. Is there some other approach to map string date directly?
In dozer.xml we can specify some default configuration.
for eg.
<configuration>
<stop-on-errors>true</stop-on-errors>
<date-format>dd-MM-yy</date-format>
<wildcard>true</wildcard>
</configuration>
here is Link to refer.

Ant propertyfile replacing value issue

I'm trying to change values in my application.properties file and I'm running into issues with an extra "\" character when trying to substitute url addresses. It doesn't happen when I'm replacing regular text.
Here's the section of the properties file I'm attempting to modify:
# Web Info
web.url=http://www.testaddress.com
web.user=TestAccount
Here's the section of my script that's not working correctly:
<propertyfile file="application.properties">
<entry key="web.url" operation="=" value="${webaddress}" />
<entry key="web.user" operation="=" value="${username}" />
</propertyfile>
What happens is that the web.user is replaced just fine but the address comes out looking like so:
# Web Info
web.url=http\://www.realaddress.com
web.user=RealAccount
I can't account for the backslash, if I echo the ${webaddress} variable it doesn't have it. Any idea as to what may be going on?
Thanks.
Check out the "store" method of the Properties object. The javadoc specifically states:
The key and element characters #, !,
=, and : are written with a preceding backslash to ensure that they are
properly loaded.

Resources