python - psycopg update doesn't work -


i'm trying use psycopg update rows in postgres database , doesn't anything, script runs without error database doesn't change.

import psycopg2  conn = psycopg2.connect("dbname=timetrack user=n") cur = conn.cursor() cur.execute("select id, extract(epoch begin_time) b, extract(epoch end_time) e activities;") rows = cur.fetchall()  m = 10 ** 6 in range(0, len(rows)):     row = rows[i]     print(row)     cur.execute("update activities set begin=(%s), \"end\"=(%s) id=(%s);",             (row[0] * m, row[1] * m, row[2]))  conn.commit() cur.close() conn.close() 

it turns out made mistake in indexing of row variable. wanted set begin begin, end end, , id id in string. however, ended setting begin id, end begin, , id begin. postgres couldn't find rows update because ids wrong, did nothing.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -