根据PEP249,Cursor.execute没有定义的返回值。 pyodbc,然而,似乎使它返回一个游标对象;文档也这么说,虽然相当简短:
execute (...)
C.execute(sql, [params]) --> Cursor
这是否有更详细的保证/记录?
查看身份,返回的对象似乎是完全相同的游标,也许用于链接调用?
>>> thing_called_cursor = conn.cursor()
>>> result = thing_called_cursor.execute("SELECT * FROM Item")
>>> result
<pyodbc.Cursor object at 0x10b3290f0>
>>> thing_called_cursor
<pyodbc.Cursor object at 0x10b3290f0>
Run Code Online (Sandbox Code Playgroud)
还,
>>> id(result)
4482830576
>>> id(thing_called_cursor)
4482830576
Run Code Online (Sandbox Code Playgroud)
我可以尝试查看来源,但我宁愿不依赖我在那里找到的任何东西。也许最好忽略当前返回的任何内容,Cursor.execute因为这样做最符合 PEP 中的规范?