Re: Binding and custom types...
Tim Roberts <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Organization | Providenza & Boekelheide, Inc. |
| Message-ID | <[email protected]> |
Douglas Mayle wrote:
> 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)"})
>
>
> What's coming includes this: SET
> location=E'ST_TRANSFORM(''SRID=900913;010100000033c4b12e6e5544408f554acff48652c0'',
> 2163)'
>
> Where I need it to be SET
> location=ST_TRANSFORM('SRID=900913;010100000033c4b12e6e5544408f554acff48652c0',
> 2163)
>
> In other words, it's a SQL function, not a text string. Is there
> anyway to call execute so that it won't escape my string?
Yes, but only by skipping the automatic quoting. Change the "," after
the query string to a "%". As long as you know there are no SQL
injection possibilities, you don't need the automatic quoting.
--
Tim Roberts, [email protected]
Providenza & Boekelheide, Inc.