From: <no...@so...> - 2002-12-13 07:16:17
|
Bugs item #653044, was opened at 2002-12-12 19:24 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=653044&group_id=16528 Category: None Group: None Status: Open Resolution: None >Priority: 7 Submitted By: Ondrej Palkovsky (ondrap) >Assigned to: Billy G. Allie (ballie01) Summary: DateTimeDelta does not work if >= 1 day Initial Comment: I think it is self-describing. It works for Delta up to 1 day though. The following works: c.execute("insert into test values (cast(%s as interval))",(t.seconds,)) so I guess something like: if isinstance(value,DateTime.DateTimeDeltaType): return 'cast(%s as interval)' % value.seconds in the quotation function would do it. Problem reproduction: ondra2=> create table test (a interval); CREATE ondra2=> \q ondra@linux:~$ python >>> from pyPgSQL import PgSQL >>> a = PgSQL.connect('::ondra2') >>> c = a.cursor() >>> from mx import DateTime >>> t = DateTime.Parser.TimeDeltaFromString('2 days') >>> t <DateTimeDelta object for '2:00:00:00.00' at 82aba40> >>> c.execute("insert into test values (%s)",(t,)) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 2671, in execute raise OperationalError, msg libpq.OperationalError: ERROR: Bad interval external representation '2:00:00:00.00' ---------------------------------------------------------------------- >Comment By: Billy G. Allie (ballie01) Date: 2002-12-13 02:16 Message: Logged In: YES user_id=8500 Ondrej, The underlying problem is an incompatibility of the formats used for intervals in PostgreSQL and DateTimeDeltas in mx. In your example, the 2:00:00:00.00 would have to be cast as '2 days 00:00:00.00' for PostgreSQL to accepts. There is also a problem with intervals > 1 day begin returns from PostgreSQL. The returned string can't be parsed by mx.DateTime.DateTimeDeltaFromString. I am working on a fix for the problem. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=116528&aid=653044&group_id=16528 |