1

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?

1
  • 1
    Use an UPDATE Statement to change values in existing rows. Commented Jul 20, 2016 at 13:09

1 Answer 1

4

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.