Thread: [cx-oracle-users] Timestamp datatype doesn't display fractions of a second
Brought to you by:
atuining
From: Chris D. <cdu...@ya...> - 2004-07-21 13:03:06
|
Hi, I'm unable to get cx_Oracle to fully display an Oracle 9i Timestamp column: >>> cur = db.cursor() >>> cur.execute("select order_date from oe.orders where rownum < 2") [<TimestampVar object at 0x007EB260>] >>> print cur.description [('ORDER_DATE', <type 'TimestampVar'>, -1, 11, 0, 0, 0)] >>> data = cur.fetchall() >>> print data[0][0] 1999-08-16 22:34:12 >>> type(data[0][0]) <type 'ExternalDateTimeVar'> As you can see the fractions of second aren't being displayed. Maybe there's a clue in that the column is actually being returned into an ExternalDateTimeVar type not a TimestampVar defined by the cursor. This could easily be me jumping to conclusions. I'm running 4.0.1 on a 9.2 client on Windows against a 9.2.0.4 database on Linux. Thanks, Chris Dunscombe Reg __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail |
From: Anthony T. <an...@co...> - 2004-07-22 14:17:19
|
The __str__ method for the timestamp implementation of cx_Oracle does not include the fractional seconds. That doesn't mean that they are not actually there -- they are. Take a look at the documentation for the date object and you will see what I mean. I'd give you the information myself but right now I am on vacation and have limited access to a computer. Chris Dunscombe wrote: > Hi, > > I'm unable to get cx_Oracle to fully display an Oracle 9i Timestamp column: > > >>>>cur = db.cursor() >>>>cur.execute("select order_date from oe.orders where rownum < 2") > > [<TimestampVar object at 0x007EB260>] > >>>>print cur.description > > [('ORDER_DATE', <type 'TimestampVar'>, -1, 11, 0, 0, 0)] > >>>>data = cur.fetchall() >>>>print data[0][0] > > 1999-08-16 22:34:12 > >>>>type(data[0][0]) > > <type 'ExternalDateTimeVar'> > > As you can see the fractions of second aren't being displayed. > > Maybe there's a clue in that the column is actually being returned into an ExternalDateTimeVar > type not a TimestampVar defined by the cursor. This could easily be me jumping to conclusions. > > I'm running 4.0.1 on a 9.2 client on Windows against a 9.2.0.4 database on Linux. > > Thanks, > > Chris Dunscombe > > Reg > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail - 50x more storage than other providers! > http://promotions.yahoo.com/new_mail > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |
From: Chris D. <cdu...@ya...> - 2004-07-26 16:33:47
|
Anthony, Thanks for that, I can now get the fsecond data. Is there another way to get the full timestamp data, as a string, apart from: fullTimestamp = str(timestampCol) + "." + str(timestampCol.fsecond) where timestampCol is a TimestampVar object returned from a cursor. Thanks, Chris PS This can wait so enjoy your holiday --- Anthony Tuininga <an...@co...> wrote: > The __str__ method for the timestamp implementation of cx_Oracle does > not include the fractional seconds. That doesn't mean that they are not > actually there -- they are. Take a look at the documentation for the > date object and you will see what I mean. I'd give you the information > myself but right now I am on vacation and have limited access to a computer. > > Chris Dunscombe wrote: > > > Hi, > > > > I'm unable to get cx_Oracle to fully display an Oracle 9i Timestamp column: > > > > > >>>>cur = db.cursor() > >>>>cur.execute("select order_date from oe.orders where rownum < 2") > > > > [<TimestampVar object at 0x007EB260>] > > > >>>>print cur.description > > > > [('ORDER_DATE', <type 'TimestampVar'>, -1, 11, 0, 0, 0)] > > > >>>>data = cur.fetchall() > >>>>print data[0][0] > > > > 1999-08-16 22:34:12 > > > >>>>type(data[0][0]) > > > > <type 'ExternalDateTimeVar'> > > > > As you can see the fractions of second aren't being displayed. > > > > Maybe there's a clue in that the column is actually being returned into an ExternalDateTimeVar > > type not a TimestampVar defined by the cursor. This could easily be me jumping to conclusions. > > > > I'm running 4.0.1 on a 9.2 client on Windows against a 9.2.0.4 database on Linux. > > > > Thanks, > > > > Chris Dunscombe > > > > Reg > > > > > > > > > > __________________________________ > > Do you Yahoo!? > > Yahoo! Mail - 50x more storage than other providers! > > http://promotions.yahoo.com/new_mail > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by BEA Weblogic Workshop > > FREE Java Enterprise J2EE developer tools! > > Get your free copy of BEA WebLogic Workshop 8.1 today. > > http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click > > _______________________________________________ > > cx-oracle-users mailing list > > cx-...@li... > > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Anthony T. <an...@co...> - 2004-08-16 21:02:35
|
Apologies for the delay. I was going through all of my e-mail from my holiday and came across this one. :-) Currently this is the only way of extracting that data. The datetime module checks to see if the fractional seconds are zero and if so does not display the fractional seconds; otherwise it does. I could do the same thing if that makes sense. BTW, your implementation should probably use something like "%s.%.6d" or something similar so that the fractional seconds portion is zero filled. Chris Dunscombe wrote: > Anthony, > > Thanks for that, I can now get the fsecond data. > Is there another way to get the full timestamp data, as a string, apart from: > > fullTimestamp = str(timestampCol) + "." + str(timestampCol.fsecond) > where timestampCol is a > TimestampVar object returned from a cursor. > > Thanks, > > Chris > > PS This can wait so enjoy your holiday > > > > > --- Anthony Tuininga <an...@co...> wrote: > >>The __str__ method for the timestamp implementation of cx_Oracle does >>not include the fractional seconds. That doesn't mean that they are not >>actually there -- they are. Take a look at the documentation for the >>date object and you will see what I mean. I'd give you the information >>myself but right now I am on vacation and have limited access to a computer. >> >>Chris Dunscombe wrote: >> >> >>>Hi, >>> >>>I'm unable to get cx_Oracle to fully display an Oracle 9i Timestamp column: >>> >>> >>> >>>>>>cur = db.cursor() >>>>>>cur.execute("select order_date from oe.orders where rownum < 2") >>> >>>[<TimestampVar object at 0x007EB260>] >>> >>> >>>>>>print cur.description >>> >>>[('ORDER_DATE', <type 'TimestampVar'>, -1, 11, 0, 0, 0)] >>> >>> >>>>>>data = cur.fetchall() >>>>>>print data[0][0] >>> >>>1999-08-16 22:34:12 >>> >>> >>>>>>type(data[0][0]) >>> >>><type 'ExternalDateTimeVar'> >>> >>>As you can see the fractions of second aren't being displayed. >>> >>>Maybe there's a clue in that the column is actually being returned into an ExternalDateTimeVar >>>type not a TimestampVar defined by the cursor. This could easily be me jumping to conclusions. >>> >>>I'm running 4.0.1 on a 9.2 client on Windows against a 9.2.0.4 database on Linux. >>> >>>Thanks, >>> >>>Chris Dunscombe >>> >>>Reg >>> >>> >>> >>> >>>__________________________________ >>>Do you Yahoo!? >>>Yahoo! Mail - 50x more storage than other providers! >>>http://promotions.yahoo.com/new_mail >>> >>> >>>------------------------------------------------------- >>>This SF.Net email is sponsored by BEA Weblogic Workshop >>>FREE Java Enterprise J2EE developer tools! >>>Get your free copy of BEA WebLogic Workshop 8.1 today. >>>http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click >>>_______________________________________________ >>>cx-oracle-users mailing list >>>cx-...@li... >>>https://lists.sourceforge.net/lists/listinfo/cx-oracle-users >> >> > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com -- Anthony Tuininga an...@co... Computronix Distinctive Software. Real People. Suite 200, 10216 - 124 Street NW Edmonton, AB, Canada T5N 4A3 Phone: (780) 454-3700 Fax: (780) 454-3838 http://www.computronix.com |