Python Insert Variable Into Sql Query Optimization