Re: Binding and custom types...

Douglas Mayle <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Jun 11, 2009, at 7:03 PM, Federico Di Gregorio wrote:

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

I wish I had that leeway, I've been trying to accomplish just that,  
but failing that, I was looking for a workaround...

Thanks,
Doug

>
>
> -- 
> 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
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.