ctypes port of psycopg2