Subversion Repositories SmartDukaan

Rev

Rev 14094 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14094 manish.sha 1
import MySQLdb
2
 
3
db = MySQLdb.connect('localhost',"root","shop2020","warehouse" )
4
cursor = db.cursor()
5
 
6
def processPurchaseOrdersClosure():
7
    sql = "select id, poValidityLimit from supplier"
8
    print sql
9
 
10
    cursor.execute(sql)
11
    result = cursor.fetchall()
12
 
13
    for rec in result:
14
        updateSql = "update purchaseorder set status = 3 where supplierId = %d and DATE(createdAt) < DATE(SUBDATE(NOW(), %d))"%(rec[0],rec[1])
15
        print updateSql
16
        try:
14095 manish.sha 17
            # Execute the update SQL command
14094 manish.sha 18
            cursor.execute(updateSql)
19
            # Commit your changes in the database
20
            db.commit()
21
        except:
22
            # Rollback in case there is any error
23
            db.rollback()
24
 
25
def main():
26
    processPurchaseOrdersClosure()
27
 
28
 
29
if __name__=='__main__':
30
    main()