Re: Passing Parameters to copy_expert()?
От | Daniele Varrazzo |
---|---|
Тема | Re: Passing Parameters to copy_expert()? |
Дата | |
Msg-id | CA+mi_8aPZX1nXWSD8UyML2csscmm9fK6KpQnBhfLdQ3T=bkAxw@mail.gmail.com обсуждение исходный текст |
Ответ на | Passing Parameters to copy_expert()? (Victor Hooi <victorhooi@yahoo.com>) |
Список | psycopg |
On Fri, Nov 8, 2013 at 8:22 AM, Victor Hooi <victorhooi@yahoo.com> wrote: > Hi, > > I'm trying to use the copy_expert() command to dump records from a database > to CSV. > > http://initd.org/psycopg/docs/cursor.html#cursor.copy_expert > > However, I need to pass some parameters into the SQL statement - namely the > values for a WHERE IN clause. > > (Basically, the COPY operation is too big for our PostgreSQL server to > handle, so we're chunking it up into multiple queries - hence, needing to > pass in values to WHERE IN). > > I can't seem to see anything in the docs about this about how to pass > parameters through to copy. > > I could use Python's own string interpolation, however, I'm under the > impression that's a pretty bad thing. > > Is there another way to pass parameters to copy_expert()? Hello Victor, unfortunately no, copy doesn't support parameters. It seems an useful feature. Even if it is meant for debugging purpose you can use cursor.mogrify(query, args) that would return you the query merged with the argument and pass such result to copy_expert(). http://initd.org/psycopg/docs/cursor.html#cursor.mogrify Hope this helps. -- Daniele
В списке psycopg по дате отправления: