码迷,mamicode.com
首页 > 数据库 > 详细

python之数据库表迁移

时间:2016-06-30 12:25:39      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

 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 !

python之数据库表迁移

标签:

原文地址:http://www.cnblogs.com/changbo/p/5629506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!