bug fix for old psycopg2 version usage.