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

Re: Update with function

From: egbert <egbert(dot)bouwman(at)xs4all(dot)nl>
To: psycopg(at)postgresql(dot)org
Subject: Re: Update with function
Date: 2012-03-30 16:02:40
Message-ID: 1333123360.11432.7.camel@para.lan (view raw or flat)
Thread:
Lists: psycopg
On Fri, 2012-03-30 at 06:45 -0700, Adrian Klaver wrote:

> A simple solution that demonstrates one way to do the above:
> 
> 
> cur.execute("select recno from some_table")
> 
> for row in cur:
> 	recno = cur[0]
> 	cur.execute("update books set inyear=%s", (makeyear(recno),))
> 
Thanks for your suggestion, Adrian.
Actually, that was something I tried first.
But my some_table is about 165000 records, and it took nearly three
hours (on my not so young system) to run the individual updates.
So I looked for a one-pass solution.
egbert

-- 
Egbert Bouwman  
Keizersgracht 197-II    
1016 DS  Amsterdam      
Tel 0(031)20 6257991


In response to

Responses

psycopg by date

Next:From: Adrian KlaverDate: 2012-03-30 16:05:04
Subject: Re: Update with function
Previous:From: Adrian KlaverDate: 2012-03-30 13:45:35
Subject: Re: Update with function

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