[DB-SIG] informixdb module problem
John Mitchell
johnm@magnet.com
Fri, 2 Oct 1998 10:25:14 -0400 (EDT)
On Fri, 2 Oct 1998, Anthony M. Ingraldi wrote:
> Hello,
>
> I am having some difficulty with DATE data and the informixdb module. The
> following example illustrates the problem
>
> >>> cursor.execute("insert into table_name (a_date) values ('10/2/98')")
> 1
> >>> cursor.execute("select a_date from table_name where a_date='10/2/98'")
> >>> res = cursor.fetchall()
> >>> res
> [(<DbiDate object at eeb68>,)]
> >>> str(res[0][0])
> 'Wed Dec 31 18:59:59 1969'
I've seen the exact same symptoms: selects returning a DbiDate get the
equivalent of "-1"... Workaround: 1) swear till you're blue, and then 2)
if you dont need the date *value*, just the *string* (ie: for reports),
then change your select to return a string:
select a_date||'' from table_name
The "||" is Informix's string-concatanate.
(I'm using Python 1.5, SGI Irix 6.2, informixdb 1.01 1997-03-11.)
Oh yeah: dont try to do load/unload via cursor.execute(). It doesnt work:
'unload' isnt SQL! Check:
http://outside.organic.com/mail-archives/dbi-users/Jun1997/0170.html
I've only got to step #1 above, because #2 is "add code to the C
library"...
- j