Hi,

I experienced problems with pygresql while using the pg module.
It does not quote the column names as (apparently) required in
postgresql with mixed-case column names.

Here is a diff of my modifications :
~$ diff /usr/lib/python2.4/site-packages/pg.py ./mypg.py
418c418
<                               n.append(f)
---
>                               n.append('"%s"'%f)


The problem is described by this example, mypg is the modified version, pg.

Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pg
>>> import mypg
>>> pg.version
'3.8.1'
>>> a = {'timestamp': '200707021234', 'Altitude': 2.2,
'HorizontalAccuracy': 0.0, 'VerticalAccuracy': 0.1, 'sensor_id': 1,
'luser_id': 2, 'Position': 'POINT(%s  %s)'%(2.48, 48.4)}
>>> db = pg.DB("loca")
>>> db.debug = '%s'
>>> db.insert("survey", a)
INSERT INTO public.survey
(sensor_id,timestamp,Altitude,HorizontalAccuracy,Position,VerticalAccuracy,luser_id)
VALUES (1,'200707021234',2.2,0.0,'POINT(2.48  48.4)',0.1,2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/site-packages/pg.py", line 422, in insert
    a[foid] = self.db.query(q)
pg.ProgrammingError: ERROR:  column "altitude" of relation "survey" does
not exist

>>>
>>> db2 = mypg.DB("loca")
>>> db2.debug = '%s'
>>> db2.insert("survey", a)
INSERT INTO public.survey
("sensor_id","timestamp","Altitude","HorizontalAccuracy","Position","VerticalAccuracy","luser_id")
VALUES (1,'200707021234',2.2,0.0,'POINT(2.48  48.4)',0.1,2)
SELECT * FROM public.survey WHERE oid=None LIMIT 1


Regards,



-- 
Christophe Berger
Network R&D Engineer
LIP6 - +33 144 277 277


_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql

Reply via email to