psycopg2 不执行 PostgreSQL 函数
我试图从 psycopg2
调用一个函数,如下所示:
conn = psycopg2.connect(host="name.host.ex", user="username", password="secret")
cur = conn.cursor()
cur.callproc("f_do_action", ["aaa", "bbb"])
cur.close()
conn.close()
当从 psql
调用此函数时,一切正常,但使用 psycopg2
似乎没有任何反应。我也不例外。它只是不调用实际数据库上的函数。
来自 psycopg2
的其他查询也可以工作(SELECT、INSERT
)。
I'm trying to call a function from psycopg2
like such:
conn = psycopg2.connect(host="name.host.ex", user="username", password="secret")
cur = conn.cursor()
cur.callproc("f_do_action", ["aaa", "bbb"])
cur.close()
conn.close()
When calling this function from psql
everything works fine but using psycopg2
nothing seems to happen. I get no exception. It just does not call out the function on the actual database.
Also other queries from psycopg2
work (SELECT, INSERT
).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在关闭连接之前提交:
来自 psycopg2 文档:
Try committing before closing your connection:
From psycopg2 documentation: