首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python aiopg lastrowid

Python aiopg lastrowid
EN

Stack Overflow用户
提问于 2017-09-02 23:48:57
回答 1查看 142关注 0票数 0

我正在使用asyncio和aiopg,在插入执行后,我无法获取lastrowid。

我的代码:

代码语言:javascript
复制
 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起作用了,但lastrowid没有打印,next也打印了。

如果我执行SELECT,则与fetchone()和fetchall()相同。

EN

回答 1

Stack Overflow用户

发布于 2017-09-03 15:54:01

cursor.lastrowid是一个常规属性,请在访问它之前删除await

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46015525

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档