标签:
1 #!/usr/local/bin/python3.5 2 #coding:utf-8 3 import pymysql 4 import datetime 5 Host = ‘xxxxxxxx‘ 6 User = ‘xxxxxx‘ 7 Pass = ‘xxxxxx‘ 8 Db = ‘xxxxxxx‘ 9 10 db = pymysql.connect(Host, User, Pass, Db) 11 cursor = db.cursor() 12 sql = ‘‘‘ 13 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 14 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx15 16 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 17 18 19 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx21 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; 22 23 ‘‘‘ 24 try: 25 starttime = datetime.datetime.now() 26 cursor.execute(sql) 27 db.commit() 28 endtime = datetime.datetime.now() 29 print(u"执行成功......\n共运行:", (endtime - starttime).seconds, ‘s‘) 30 except Exception as e: 31 print(e) 32 db.rollback() 33 34 db.close()
END !
标签:
原文地址:http://www.cnblogs.com/changbo/p/5629506.html