psycopg2 not actually inserting data

You didn't commit the transaction.

Psycopg2 opens a transaction automatically, and you must tell it to commit in order to make the data visible to other sessions.

See the psycopg2 FAQ and the connection.commit() method.


Just had the same perplexing issue. To put options together:

as @Craig Ringer writes after cursor.execute you can run connection.commit

cursor.execute('INSERT INTO table VALUES(DEFAULT, %s)', email)
...
connection.commit()

OR after connect set autocommit

connection = connect("user='pguser' host='localhost' dbname='pgdb' password='pgpass'")
connection.autocommit = True

OR use set_session to set autocommit

connection = connect("user='pguser' host='localhost' dbname='pgdb' password='pgpass'") 
connection.set_session(autocommit=True)

All worked for me.