def initialize(self):
"""Initialize SQL database in the correct state"""
for name, ddl in self.DROP.iteritems():
try:
print "Drop table {}:".format(name),
self.cursor.execute(ddl)
except MySQLdb.Error as err:
print err
except MySQLdb.Warning as wrn:
pass
finally:
print 'OK'
for name, ddl in self.TABLES.iteritems():
try:
print "Creating table {}:".format(name),
self.cursor.execute(ddl)
except MySQLdb.Error as err:
print err
except MySQLdb.Warning as wrn:
pass
finally:
print 'OK'
for name, ddl in self.INSERT.iteritems():
try:
print "Inserting into table {}:".format(name),
self.cursor.execute(ddl)
except MySQLdb.Error as err:
print err
except MySQLdb.Warning as wrn:
pass
finally:
print 'OK'
sqlhandler.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录