14

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).

1 Answer 1

17

Try committing before closing your connection:

cur.close()
conn.commit()
conn.close()

From psycopg2 documentation:

Note that closing a connection without committing the changes first will cause any pending change to be discarded as if a ROLLBACK was performed (unless a different isolation level has been selected: see set_isolation_level()).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.