proper psycopg2 usage