Consider the following table OrderDetails of database sales
ORDNUMB | PARTNUMB | NUMBORD | QUOTPRIP |
12494 | CB03 | 4 | 175 |
12495 | CX11 | 2 | 57.95 |
12498 | AZ52 | 2 | 22.95 |
12500 | BT04 | 1 | 402.99 |
Write Python code to increase NUMBORD by 5 if QUOTPRIC is less than 100 or NUMBORD is greater than 3.
Answer:
import mysql.connector.connect
db=mysql.connector.connect('localhost','root','root','sales')
cursor=db.cursor()
sql="UPDATE OrderDetails set NUMBORD=NUMBORD+5 where QUOTPRIC<100 OR NUMBORD>3"
try:
cursor.execute(sql)
db.commit()
except:
db.rollback()
db.close()