0
下面是我RUN_SQL功能:为什么“cursor.lastrowid”返回3?
def RUN_SQL_SAFE(sql, input_tuple=(), get_update_id=False, debug = False):
conn = GET_MYSQL_CONNECTION()
cursor = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)
cursor.execute(sql, input_tuple)
conn.commit()
if get_update_id:
res = cursor.lastrowid
cursor.close()
conn.close()
if get_update_id:
return res
我运行使用“RUN_SQL_SAFE(SQL,元组,真)”,这里的SQL是一个插入SQL和表是空的,但有3回RES我不知道我的代码知道为什么它不会返回1? 感谢
定义函数时,不需要[留言](http://email.about.com/od/netiquettetips/qt/Writing-In-All-Caps-Is-Like-Shouting.htm)。看看[PEP 8](http://www.python.org/dev/peps/pep-0008/)。 – glglgl 2012-04-03 07:29:22