Python Forum
Unable to read update access DB
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to read update access DB
#1
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()
Error:
File "C:/MyPython/MyTest.py", line 9 sql= """ Update EMPTBL SET sal=mysal*.25""" ^ IndentationError: expected an indented block Process finished with exit code 1
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read csv file update matplotlib column chart regularly SamLiu 2 1,016 Jan-21-2023, 11:33 PM
Last Post: SamLiu
  |SOLVED] Glob JPGs, read EXIF, update file timestamp? Winfried 5 2,414 Oct-21-2021, 03:29 AM
Last Post: buran
  Unable to access jarfile Rakshan 2 2,583 Jul-28-2021, 11:10 AM
Last Post: Rakshan
  Unable to access the user input value given to daterangepicker klllmmm 1 2,269 May-26-2021, 09:16 PM
Last Post: nilamo
Question Python + Google Sheet | Best way to update specific cells in a single Update()? Vokofe 1 2,628 Dec-16-2020, 05:26 AM
Last Post: Vokofe
  Unable to Update SQLite Table sambanerjee 5 2,868 Sep-30-2020, 12:21 PM
Last Post: Larz60+
  Unable to read from serial port br0kenpixel 1 2,428 Aug-08-2020, 10:03 PM
Last Post: Larz60+
  unable to update packages russianponchik 0 1,615 Mar-29-2020, 04:18 PM
Last Post: russianponchik
  Unable to read decimal datatype using pandasql geethchi 0 2,010 Oct-25-2019, 05:56 PM
Last Post: geethchi
  Passing Values of Dictionaries to Function & Unable to Access Them firebird 3 2,533 Aug-03-2019, 10:25 PM
Last Post: firebird

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020