I am new to python and struggling with creating a dynamic if statement. I have a set of queries that are run against various databases/tables. The result is all the same in that I always get back the same field names.
What I want to do is total the results differently based on the table. so for instance I query fld1, fld2, fld3, qty, qty2 from table1 then I loop thru the results if fld1 = 'a' add qty to some_total1 I query fld1, fld2, fld3, qty, qty2 from table2 then I loop thru the results if fld2 = 'b' add qty to some_total1 I query fld1, fld2, fld3, qty, qty2 from table3 then I loop thru the results if fld3 = 'c' add qty2 to some_total1 I created a database pair that contains (table1,fld1 = 'a',add qty to some_total1) (table2,fld2 = 'b',qty to some_total1) (table3,fld3 = 'c',qty2 to some_total1) So I know which table I am using, I query my list pair but I cant see how to build the if statement using the results from the query. something like this would be the result var1 = "fld1 = 'a'" result = "add qty to some_total1" if var1: result -- http://mail.python.org/mailman/listinfo/python-list