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 | <1244739801.4386.2.camel@erin> |
Il giorno gio, 11/06/2009 alle 18.40 +0200, Douglas Mayle ha scritto:
> Hello all,
> I was wondering if someone could help me figure out an issue
> I'm
> having using psycopg2 by way of SQLAlchemy because of my bind
> parameter. I'm running something like this:
> >
> cursor.execute('UPDATE almanacs SET location=%(location)s,
> modified=CURRENT_TIMESTAMP WHERE almanacs.id = %(almanacs_id)s',
> {'almanacs_id': 2, 'location':
> "ST_TRANSFORM
> ('SRID=900913;01010000007f2ef1fb0b804640cdfc51710f0059c0', 2163)"})
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}
)
--
Federico Di Gregorio http://people.initd.org/fog
DISCLAIMER. If I receive a message from you, you are agreeing that:
1. I am by definition, "the intended recipient".
2. All information in the email is mine to do with as I see fit and
make such financial profit, political mileage, or good joke as it lends
itself to. In particular, I may quote it on USENET or the WWW.
3. I may take the contents as representing the views of your company.
4. This overrides any disclaimer or statement of confidentiality that
may be included on your message.
_______________________________________________
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) iEYEABECAAYFAkoxONIACgkQvcCgrgZGjetPrgCgtGsdGh+DuBdf5NkfQgblC3Yq 9SQAniGfec8rVOjZIuaTRRxIScUO/sz/ =UTtq -----END PGP SIGNATURE-----