Unable to read update access DB - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Unable to read update access DB (/thread-21298.html) |
Unable to read update access DB - saaketh - Sep-23-2019 Access DB - Table Name - EMPTBL Coloumns Names Sal(with Values),cca(No Values),Hra(No Values),NS(No Values),GS(No Values) I want to calculate CCA HRA NS GS, based on sal(salary) and update the table EMPTBL import pyodbc conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\MyPython\Mydb.accdb;') cursor = conn.cursor() Mysal= cursor.execute('select sal from EMPTBL') if Mysal > 5000: sql= """ Update EMPTBL SET sal=mysal*.25""" cursor.execute(sql) cursor.commit() conn.close()
RE: Unable to read update access DB - Malt - Sep-24-2019 From the error itself you can get it I hope. Conditions or loops should maintain its indentation. If you are a newbie, take some basic tutorials which will help you to avoid all the basic issues like this |