Re: Binding and custom types...

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization initd.org
Message-ID <1244741071.7004.1.camel@erin>
Il giorno gio, 11/06/2009 alle 19.18 +0200, Douglas Mayle ha scritto:
> > I'd rewrite it like this:
> >
> > cursor.execute("""UPDATE almanacs SET
> >                         location=ST_TRANSFORM(%(srid)s,%(num)s),
> >                          modified=CURRENT_TIMESTAMP
> >                   WHERE almanacs.id = %(almanacs_id)s""",
> >  {'almanacs_id': 2,
> >   'srid': "SRID=900913;01010000007f2ef1fb0b804640cdfc51710f0059c0",
> >   'num': 2163}
> > )
> 
> I wish I had that leeway, I've been trying to accomplish just that,  
> but failing that, I was looking for a workaround...

Or you can wrap your value into an AsIs object.

from psycopg2.extensions import AsIs

cursor.execute(..., {...
    'location': AsIs("ST_TRANSFORM('SRID=900913;01010000007f2ef1fb0b804640cdfc51710f0059c0', 2163)")
})

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           fog-NGVKUo/i/[email protected]
 Ubuntu is an ancient African word meaning "I can't configure Debian".
                                                     -- somewhere on IRC

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkoxPc8ACgkQvcCgrgZGjeslkACfej7fXh+XjofhemayFmQ/kS0J
oqAAoNLmgd+gc0No3vGHKcX68GmdUnAp
=uY1y
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.