Starting intergration of query code into python program