I've looked at the documentations but haven't found anything that lets me know if the last command i've execute via cursor.execute("...") is successful.
I'm expecting a reply like "1 row affected."
I've looked at the documentations but haven't found anything that lets me know if the last command i've execute via cursor.execute("...") is successful.
I'm expecting a reply like "1 row affected."
I'd expect some kind of exception to be risen.
If everything went ok – the error code is 00000 and no exception will get risen.
In
create table
case, you can always double check:This is an old question, but one way to check for a successful operation with
psycopg2
is simply to look at therowcount
attribute for the cursor after your statement. This attribute returns the number of rows affected by the lastexecute
statement.e.g.
A similar attribute is
statusmessage
, which returns a string including the type of the last operation performed along with the number of rows affected.