ameliabob 3 Posted July 28, 2018 Report Share 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? Quote Link to post Share on other sites
Ingolme 1,019 Posted July 28, 2018 Report Share 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. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.