switch from psql wrapper to psycopg2