Re: Unpacking a Python list in a query.
От | Israel Ben Guilherme Fonseca |
---|---|
Тема | Re: Unpacking a Python list in a query. |
Дата | |
Msg-id | BANLkTi=jbxsNanQOk_9+eL24zDm9yLRuRA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Unpacking a Python list in a query. (Sukhbir Singh <singheinstein@gmail.com>) |
Список | psycopg |
Hmm, I was trying to remember why lists and tuples were different and found this in the docs:
Python lists are converted into PostgreSQL ARRAYs:Just remember that. :)
Python lists are converted into PostgreSQL ARRAYs:
>>> cur.mogrify("SELECT %s;", ([10, 20, 30], ))
'SELECT ARRAY[10, 20, 30];'
Python tuples are converted in a syntax suitable for the SQL IN operator and to represent a composite type:
>>> cur.mogrify("SELECT %s IN %s;", (10, (10, 20, 30)))
'SELECT 10 IN (10, 20, 30);'
2011/6/24 Sukhbir Singh <singheinstein@gmail.com>
Hi,Indeed, it does work. I somehow didn't try the most obvious solution
> Actually, a list or a tuple will work just fine.
to this, focusing on unpacking all the time :-)
Thank you.
--Sent via psycopg mailing list (psycopg@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/psycopg
В списке psycopg по дате отправления: