我正在使用asyncio和aiopg,在插入执行后,我无法获取lastrowid。
我的代码:
async with aiopg.create_pool(self.connect, loop=self._loop) as pool:
async with pool.acquire() as connect:
async with connect.cursor() as cursor:
await cursor.execute("INSERT INTO users(user_firstname,user_lastname) VALUES('Johan', 'Smith')")
print(await cursor.lastrowid)
print(' - - - ')
pass
pass
pass
passExecute起作用了,但lastrowid没有打印,next也打印了。
如果我执行SELECT,则与fetchone()和fetchall()相同。
发布于 2017-09-03 15:54:01
cursor.lastrowid是一个常规属性,请在访问它之前删除await。
https://stackoverflow.com/questions/46015525
复制相似问题