Python: add support to query history data.

@lepture Please reveiw it. Thanks.