This is an old question, but one way to verify that psycopg2 works successfully is to simply look at the rowcount attribute for the cursor after your statement. This attribute returns the number of lines affected by the last execute .
eg.
connection = psycopg2.connect(dbname="foo",user="postgres") cur = connection.cursor() cur.execute("INSERT INTO foo VALUES (%s, %s)", (1,2)) cur.rowcount # returns 1 cur.execute("SELECT * FROM foo") cur.rowcount # returns 0
A similar attribute is messagestatus , which returns a string that includes the type of the last operation performed along with the number of rows affected.
source share