added query_gages.py code