port to psycopg