q="update student set mark=mark+5 WHERE id =7"
r_set=my_conn.execute(q)
print("Records updated")
q="UPDATE student set class='Five' WHERE class='Four' "
try:
r_set=my_conn.execute(q)
print("Records updated")
except sqlite3.Error as my_error:
print("error: ",my_error)
Output
Records updated
print(r_set.rowcount) # 9
from sqlalchemy.exc import SQLAlchemyError
q="UPDATE STUDENT set mark=mark+1"
try:
r_set=my_conn.execute(q)
except SQLAlchemyError as e:
error=str(e.__dict__['orig'])
print(error)
else:
print("No of records updated : ",r_set.rowcount)
my_data=('Seven','Six') # tuple to pass values to execute method
q="UPDATE student set class=? WHERE class=? "
try:
r_set=my_conn.execute(q,my_data)
print("Records updated : ",r_set.rowcount)
except sqlite3.Error as my_error:
print("error: ",my_error)
Output
Records updated : 1
Updating single records
q="update student set mark=mark+5 WHERE id =9"
r_set=my_conn.execute(q)
print("Records updated : ",r_set.rowcount)
Output
Records updated : 1
Sqlite Update Binary data by using Blob Column
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.