Re: About mogrify
paftek <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Nov 19, 2008 at 6:02 PM, Federico Di Gregorio <fog-NGVKUo/i/[email protected]> wrote: > On Wed, Nov 19, 2008 at 05:46:30PM +0100, paftek wrote: >> Actually I am using mogrify() to generate multi rows INSERT statements >> from a list of values : >> Is there a better way to do this without mogrify() ? > > You can use executemany() but it will generate multiple INSERT > statements while you use a single multi-row statement. There is > any good reason to use multi row instead of using psycopg's > executemany()? > > federico Speed ! http://www.depesz.com/index.php/2007/07/05/how-to-insert-data-to-database-as-fast-as-possible/ I also use mogrify() to add WHERE conditions to my queries according to what the user decides to filter on. SELECT * FROM item WHERE user_id = 1 AND price > 10 -- added using mogrify() AND quantity > 50 -- added using mogrify() Actually I can not live without mogrify() :) Julien