blog-python-app icon indicating copy to clipboard operation
blog-python-app copied to clipboard

_update问题

Open RobinHxn opened this issue 8 years ago • 0 comments

@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方法? 结果图: image

RobinHxn avatar Mar 31 '17 10:03 RobinHxn