简体   繁体   中英

Modify values in an existing table of MS Access using Python

I am trying to change a value of a whole column in MS Access database with python using pypyodbc. So far I have only found a way to create a new line but not modify the existing values.

This code is from another question I found and it works but only to create a new line (the table name is Table 1 and the column is Testie not that it really matters)

conn=pypyodbc.win_connect_mdb("C:\Users\y.johannes1\Documents\prufa.mdb")
cursor=conn.cursor()
sql= """ INSERT INTO Table1(Testie) Values(10)"""
cursor.execute(sql)
cursor.commit()
conn.close()

Any ideas?

This worked if anyone has the same problem

conn=pypyodbc.win_connect_mdb("C:\Users\y.johannes1\Documents\prufa.mdb")
cursor=conn.cursor()
sql= """ Update Table1 SET testie=7 WHERE id=1"""
cursor.execute(sql)
cursor.commit()
conn.close()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM