Skip site navigation (1) Skip section navigation (2)

Batch updates to 1 column using python-pgsql in multiple rows

From: Abhijeet R <abhijeet(dot)1989(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Batch updates to 1 column using python-pgsql in multiple rows
Date: 2012-08-29 13:58:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Hi guys,

I have to update a certain column of a table at many rows. (order of 

For now, I am using a prepare statement and executing the queries like:

query = "UPDATE mytable SET myvar = $1 WHERE myvar2=$2"
db.execute(query, (var, var1)) #db is my connection object

But, I still feel like I can make it faster by using db.executemany() 
method.  The thing is I am not able to get the syntax of it.

Can anyone please guide me as to how do I do batch updates in the 
fastest possible manner? Also, will executemany() really be faster? If 
so, how does that result in faster batch updates?



pgsql-novice by date

Next:From: Tom LaneDate: 2012-08-29 15:03:15
Subject: Re: question about logging_collector
Previous:From: Bartosz DmytrakDate: 2012-08-29 11:47:25
Subject: Re: Problem with CREATE TRIGGER

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group