Postgres Max Function In Python