I wish I could pass bound variables as a dictionary not a list

Поиск
Список
Период
Сортировка
От W. Matthew Wilson
Тема I wish I could pass bound variables as a dictionary not a list
Дата
Msg-id CAGHfCUDwLAZUnBRYD0WC4TXhuxw6r5Rx6xZcqhDp8U3zFU+mfQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: I wish I could pass bound variables as a dictionary not a list
Список psycopg
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?

Matt



--
W. Matthew Wilson
matt@tplus1.com
http://tplus1.com

В списке psycopg по дате отправления: