Rev 14094 | Blame | Compare with Previous | Last modification | View Log | RSS feed
import MySQLdbdb = MySQLdb.connect('localhost',"root","shop2020","warehouse" )cursor = db.cursor()def processPurchaseOrdersClosure():sql = "select id, poValidityLimit from supplier"print sqlcursor.execute(sql)result = cursor.fetchall()for rec in result:updateSql = "update purchaseorder set status = 3 where supplierId = %d and DATE(createdAt) < DATE(SUBDATE(NOW(), %d))"%(rec[0],rec[1])print updateSqltry:# Execute the update SQL commandcursor.execute(updateSql)# Commit your changes in the databasedb.commit()except:# Rollback in case there is any errordb.rollback()def main():processPurchaseOrdersClosure()if __name__=='__main__':main()