blog-python-app
blog-python-app copied to clipboard
_update问题
@with_connection def _update(sql, *args): """ 执行update语句,返回行数 """ global _db_ctx cursor =None sql = sql.replace('?','%s') logging.info('SQL: %s, ARGS: %s' % (sql, args)) try: cursor = _db_ctx.connection.cursor() cursor.execute(sql, args) r = cursor.rowcount if _db_ctx.transactions == 0: # no transaction enviroment: logging.info('auto commit') _db_ctx.connection.commit() return r finally: if cursor: cursor.close()
执行时cursor对象没有close方法?
结果图:
