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)
评论列表
文章目录