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 & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.