sqlhandler.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:lightbulb-framework 作者: lightbulb-framework 项目源码 文件源码
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'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号