Fix for parsing timestamp field in Oracle
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
JayDeBeApi |
Confirmed
|
Medium
|
Unassigned |
Bug Description
As per comments in the code, timestamp field in Oracle doesn't get converted to string easily. I just wanted to point out that the following modification in dbapi2.py worked for me.
=======
--- dbapi2.py 2013-10-15 20:07:50.000000000 +0000
+++ dbapi2_.py 2014-01-29 02:15:03.480118533 +0000
@@ -435,6 +435,7 @@
pass
def _to_datetime(
+ java_val = java_val.toJdbc()
d = datetime.
if not isinstance(
d = d.replace(
=======
I am not sure if this will break other jdbc libraries though.
Thanks for the patch. It's indeed Oracle specific and would break other jdbc libraries. That's why I'm not going to include your patch. I've already planned but not fully implemented another optional parameter for the connect method that would allow you to specify a mapping that's specific to your database. Something similar to this:
def your_ora_ todatetime( java_val) : datetime. strptime( str(java_ val)[:19] , "%Y-%m-%d %H:%M:%S") java_val, basestring): microsecond= int(str( java_val. getNanos( ))[:6]) )
java_val = java_val.toJdbc()
d = datetime.
if not isinstance(
d = d.replace(
return str(d)
conn = connect( 'oracle. jdbc.OracleDriv er', ['jdbc: oracle: thin:@/ /foo:1521/ bar'], converters= dict(TIMESTAMP= your_ora_ todatetime) )
I'll try to implement this in the next couple of weeks if I find the time. Most of the code is already there. I think I'll include your sample implementation in the documentation.
Thank you!