ameliabob 3 Report post Posted July 28, 2018 I have the following code cur.execute("select symbol,stopPrice from holdings order by symbol" ) for row in cur: newSym =str(row[0]) if(syms==""): syms = newSym else: syms += ","+newSym holdingStops = BuildMyDict(cur) def BuildMyDict(response): myDict = dict() print(str(response)) for r in response: myDict[r[0]] = float(r[1]) return myDict When I get to the BuldMyDict it believes the cur has already completed. Is there a command that will reset the iterator counter? Share this post Link to post Share on other sites
Ingolme 939 Report post Posted July 28, 2018 First, verify that it actually can iterate through the data set twice, by trying a for loop right after the first one. If it can't iterate twice, then you call fetchall() to obtain a list and store that in another variable instead. You will be able to iterate over a generic Python list as many times as you need to. Share this post Link to post Share on other sites