[Python-projects] apycot

Didrik Pinte lists at dipole-consulting.com
Thu Mar 5 09:56:59 CET 2009


Hi Adrien,

Thanks for the answer. Here are the details :

On Thu, 2009-03-05 at 08:13 +0100, Adrien Di Mascio wrote:
> 
> The real problem is elsewhere and I can't reproduce it here. Which versions
> of python / cubicweb / postgres / psycopg are you using ? 
> Is your version of psycopg compiled with mx.DateTime support ? 

I am running a Debian/Sid system with :

python 		2.5.4-2
cubicweb 	3.1.0 (from logilab debian repository)
postregsql-8.3	 8.3.6-1
psycopg 	1.1.21-17

The psycopg package depends on python-egenix-mxdatetime. Thus, I would
think it has been compiled with mx.DateTime support.

> 
> What happens if you type the following code in a python shell :
> >>> from psycopg2 import connect
> >>> from mx.DateTime import now
> >>> cnx = connect(database='YOUR_DATABASE', user='USER_LOGIN')
> >>> crs = cnx.cursor()
> >>> crs.execute('INSERT INTO EGroup  ( eid, name, modification_date, 
> creation_date ) '
> ...             'VALUES (%(eid)s, %(name)s, %(mdate)s, %(cdate)s)', 
> ...             {'eid': 1234, 'name': 'foo', 'mdate': now(), 'cdate': now()})
> >>> 
Using psycopg 1 :

postgres at homer:~/$ python
Python 2.5.4 (r254:67916, Feb 18 2009, 03:00:47) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from psycopg import connect
>>> from mx.DateTime import now
>>> cns = connect(database="apycot", user="cubicweb")
>>> crs = cnx.cursor()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'cnx' is not defined
>>> crs = cns.cursor()
>>> crs.execute('INSERT INTO EGroup (eid, name, modification_date,
creation_date) VALUES (%(eid)s, %(name)s, %(mdate)s, %(cdate)s)',
{'eid':1234, 'name':'foo', 'mdate': now(), 'cdate':now() })
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
psycopg.ProgrammingError: ERROR:  syntax error at or near "09"
LINE 1: ...e, creation_date) VALUES (1234, 'foo', 2009-03-05
09:24:27.9...
                                                             ^

INSERT INTO EGroup (eid, name, modification_date, creation_date) VALUES
(1234, 'foo', 2009-03-05 09:24:27.95, 2009-03-05 09:24:27.95)


With psycopg2, it just works fine !

So the problem is psycopg1 related .

Didrik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.logilab.org/pipermail/python-projects/attachments/20090305/fe3819c5/attachment.pgp>


More information about the Python-Projects mailing list