0

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.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437

1 Answers1

0

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

Andrew Svetlov
  • 16,730
  • 8
  • 66
  • 69