Added savepoints to psycopg2 queries