ameliabob Posted July 28, 2018 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? Link to comment Share on other sites More sharing options...
Ingolme Posted July 28, 2018 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now