Re: 2.0.6 and mx.DateTime
Sylvain Thénault <sylvain.thenault-yG1kfhx/[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Organization | Logilab |
| Message-ID | <[email protected]> |
Le Saturday 04 April 2009 21:43:33 Ed Leafe, vous avez écrit : > I've just started a project that is running on an Ubuntu server with > psycopg2 used to connect to a PostgreSQL 8.2 backend. I'm re-using > some code that was written for psycopg 1, and expects any datetime > values to be returned as mx.DateTime values, not Python datetime > values. This works fine in psycopg1, but if I switch to psycopg2 on > the same machine, I only get back Python datetimes. > > I googled a bit, and found the following solution: > > import psycopg2 > import psycopg2.extensions > psycopg2.extensions.register_type(psycopg2._psycopg.MXDATETIME) > psycopg2.extensions.register_type(psycopg2._psycopg.MXINTERVAL) > psycopg2.extensions.register_type(psycopg2._psycopg.MXDATE) > psycopg2.extensions.register_type(psycopg2._psycopg.MXTIME) > > However, when I run this code, I get: > > File '/home/ed/testapp/model/__init__.py', line 5 in ? > psycopg2.extensions.register_type(psycopg2._psycopg.MXDATETIME) > AttributeError: 'module' object has no attribute 'MXDATETIME' > > Why are these mx constants not defined? AFAIK, this is installed from > regular apt-get repositories. And is there an alternate solution? this is a bug in the debian package, update it and it should works. -- Sylvain Thénault LOGILAB, Paris (France) Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services Python et calcul scientifique: http://www.logilab.fr/science