From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
---|---|
To: | psycopg(at)postgresql(dot)org |
Cc: | "W(dot) Matthew Wilson" <matt(at)tplus1(dot)com> |
Subject: | Re: I wish I could pass bound variables as a dictionary not a list |
Date: | 2011-07-20 00:33:48 |
Message-ID: | 201107191733.48456.adrian.klaver@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On Tuesday, July 19, 2011 5:24:06 pm W. Matthew Wilson wrote:
> Every once in a while, I have to write a big gnarly query like
>
> cursor.execute("""
> select *
> from table1
> where (%s) > 99
> and ...
> """,
>
> [a, a, b, b, c, c, a, a, b])
>
> The point being that I have to repeat lots of parameters because I use
> them in several where-clauses.
>
> It would make these queries vastly easier to read and debug if I could
> pass in bound variables as a dictionary, rather than as a tuple.
>
> Is this possible?
Yes
See here:
http://www.initd.org/psycopg/docs/usage.html#query-parameters
>
> Matt
--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Sean Moss-Pultz | 2011-07-24 07:02:45 | installation problems on OSX Lion |
Previous Message | W. Matthew Wilson | 2011-07-20 00:24:06 | I wish I could pass bound variables as a dictionary not a list |