I'm trying to move some data from a table called 'postsig' to 'usersig' in python and here's the code I'm using
cur.execute("SELECT userid FROM usersig")
userid = cur.fetchall()
for i in userid:
print(i[0])
q = """SELECT mediaid FROM postsig WHERE OWNERID = %s"""
data = (i[0],)
cur.execute(q, data)
mediaids = cur.fetchall()
mediaids2 = []
for i in mediaids:
mediaids2.append(i[0])
q2 = """UPDATE usersig SET mediaids = %s WHERE userid = %s"""
data2 = (mediaids2,i[0], )
cur.execute(q2, data2)
conn.commit()
break
in this particular piece of code
i[0] = 2716168368
mediaids2 = [1956830874667839346, 1965242936024519648, 1914749430730816263, 1796363135701978130, 1758915034963881429, 1741263757667258253]
after I execute there are no errors but also the actual table doesn't get updated. Could someone please tell me what I'm doing wrong?
Thankyou!
question from:
https://stackoverflow.com/questions/65942358/psycopg2-update-not-updating-the-table-and-also-doesnt-throw-any-errors 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…