- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经编写了一个脚本来更新 psycopg2 中的员工表,但更新没有发生,currr.execute 返回 None 对象。
我的代码
connm = psycopg2.connect(database="database", user = "user", password = "pass", host = "localhost", port = "5432")
connm.autocommit = True
sql = """ UPDATE employee SET name = %s WHERE phone_number = %s"""
curr = connm.cursor()
username = "Mike"
query = "+0123456789"
abc = curr.execute(sql, (username, query))
print abc
connm.commit()
curr.close()
此 abc 对象返回 None。
请帮助我!提前致谢!
最佳答案
引用"Psycopg – PostgreSQL database adapter for Python - execute command" :
The method returns None. If a query was executed, the returned values can be retrieved using fetch*() methods
然后,无看起来不错。恭喜:)
编辑没有效果:
你能在数据库上测试你的查询吗?
my_raw_query=curr.mogrify(sql, (username, query))
print my_raw_query
检查查询是否正确,然后在数据库上复制粘贴查询以再次检查。
关于python - Psycopg2(curr.execute)返回 NONE python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47569747/
考虑: #include #include struct node { int val; struct node *next; }; typedef struct node item;
产生幂集的函数给出了正确的输入。然而,用 append(curr) 替换 append(curr[:]) 会给出一个空列表的列表。是什么原因? def subsets(nums): def b
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 5 年前。 Improve
我想将元素列表拆分为列表列表,以便内部列表中的相邻元素满足给定条件。 一个简单的条件是相邻元素相等。那么如果输入是 List(1,1,1,2,2,3,3,3,3)输出为 List(List(1,1,1
我已经编写了一个脚本来更新 psycopg2 中的员工表,但更新没有发生,currr.execute 返回 None 对象。 我的代码 connm = psycopg2.con
我正在关注这个 Js fiddle http://jsfiddle.net/ryt3nu1v/10/ 我的结果: 我正在制作一个显示年龄的 slider ,因为我有一个跟随年龄的数组 15,25,35
我正在尝试将列表插入到 postgres 表中。 在 try 中,它在这一行失败了: curr.execute("""INSERT INTO CITY (name) values (%s);""",(
我是一名优秀的程序员,十分优秀!