[Python-projects] apycot

Adrien Di Mascio adrien.dimascio at logilab.fr
Thu Mar 5 08:13:21 CET 2009


Hi Didrik,

On Wednesday 04 March 2009 18:05:06 Didrik Pinte wrote:
> I am stuck in the creation of the cube. Seems there is a typo in the
> default user and group data :
[snip]
>   File
> "/usr/lib/python2.5/site-packages/cubicweb/server/sources/native.py",
> line 414, in doexec
>     cursor.execute(str(query), args)
> psycopg.ProgrammingError: ERROR:  syntax error at or near "17"
> LINE 1: ... creation_date ) VALUES ( 1, managers, 2009-03-04
> 17:59:31.9...
> INSERT INTO EGroup ( eid, name, modification_date, creation_date )
> VALUES ( 1, managers, 2009-03-04 17:59:31.97, 2009-03-04 17:59:31.97 )
>
> It seems to be missing quotes in the sql expression.

Missing quotes is probably just an artefact of how the error message is
displayed : we use sql queries with named substitutions as in :

  sql = 'INSERT INTO Person VALUES (%(name)s, %(birthdate)s)'
  args = {'name': "foo", 'birthdate': mydate}
  cursor.execute(sql, args)

and the error message only does :
   print sql % args

That is probably why you don't see quotes in your error message. Nevertheless, 
the query seems to be correct.

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 ? 

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()})
>>> 

If the above code works, could you print repr(query) and args where the 
exception is raised (in cubicweb/server/sources/natvie.py) ?

Cheers,

-- 
Adrien Di Mascio                              LOGILAB, Paris (France).
Formations Python,Zope,Debian,Calcul    http://www.logilab.fr/formations
Développement logiciel sur mesure:      http://www.logilab.fr/services
Informatique scientifique:              http://www.logilab.fr/science
Gestion de connaissances:               http://www.cubicweb.org/
Python in Python:     http://codespeak.net/pypy/dist/pypy/doc/index.html
-------------- 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/a7b29531/attachment.pgp>


More information about the Python-Projects mailing list