我正在使用asyncio和aiopg,在INSERT执行后我无法获得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
pass
执行工作,但lastrowid不打印,下一次打印。
与fetchone()和fetchall()相同,如果我执行SELECT。