python 异常的处理

来源:互联网 发布:淘宝开网店流程步骤 编辑:程序博客网 时间:2024/06/05 20:29

import traceback

try:    # execute this sql    cursor.execute(sql, params)    # cursor.execute(sql)    # commit to mysql datebase to execute    conn.commit()except:    print('error happens')    traceback.print_exc()    # if err happens rollback    conn.rollback()