sqlreviewDal.py 文件源码

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

项目:wizard 作者: honor100 项目源码 文件源码
def updateStatistics():
    cursor = connection.cursor()
    sql = "select id, sql_content, notes from %s" % TABLE
    cursor.execute(sql)
    result = cursor.fetchall()
    #
    for id, sql_content, notes in result:
        dxl = {'insert':0, 'delete':0, 'update':0, 'create':0, 'alter':0}
        sqlList = sql_content.lower().split(';')
        for sql in sqlList:
            for key in dxl.keys():
                if sql.strip().startswith(key):
                    dxl[key] += 1
        #
        notes = json.loads(notes)
        notes.update(dxl)
        update_sql = """update %s set notes='%s' where id=%d""" % (TABLE, json.dumps(notes), id)
        cursor.execute(update_sql)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号