update query.py to optionally return a python dict