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
  Python is unable to read file Genericgamemaker 13 3,994 Jul-19-2024, 06:42 PM
Last Post: snippsat
  sharepoint: Access has been blocked by Conditional Access policies CAD79 0 2,249 Jul-12-2024, 09:36 AM
Last Post: CAD79
  How to read csv file update matplotlib column chart regularly SamLiu 2 1,916 Jan-21-2023, 11:33 PM
Last Post: SamLiu
  |SOLVED] Glob JPGs, read EXIF, update file timestamp? Winfried 5 4,020 Oct-21-2021, 03:29 AM
Last Post: buran
  Unable to access jarfile Rakshan 2 3,948 Jul-28-2021, 11:10 AM
Last Post: Rakshan
  Unable to access the user input value given to daterangepicker klllmmm 1 2,938 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 4,068 Dec-16-2020, 05:26 AM
Last Post: Vokofe
  Unable to Update SQLite Table sambanerjee 5 4,246 Sep-30-2020, 12:21 PM
Last Post: Larz60+
  Unable to read from serial port br0kenpixel 1 3,258 Aug-08-2020, 10:03 PM
Last Post: Larz60+
  unable to update packages russianponchik 0 2,272 Mar-29-2020, 04:18 PM
Last Post: russianponchik

Forum Jump:

User Panel Messages

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