Python aiopg lastrowid

249 views Asked by At

I'm using asyncio and aiopg and after INSERT execute I can't get lastrowid.

My code:

 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

Execute worked, but lastrowid don't printed and next print too.

Same with fetchone() and fetchall(), if I executed SELECT.

1

There are 1 answers

0
Andrew Svetlov On

cursor.lastrowid is a regular property, drop await before access to it.