i have this simple for loop in flask framework
@app.route('/kde')
def fetch_erga():
cur = mysql.connection.cursor()
cur.execute("SELECT ergo FROM erga")
rv = list(cur.fetchall())
for row in rv:
stock = str(row[0]['ergo'])
tsapr += [(stock)]
return '<h2>' + tsapr + '</h2>'
This leads to jinja crashing and producing the following error in the browser: KeyError: 0
is it an error with key evaluation or the lack of it, or is it just bad looping? Any help would be aprreciated
edit: when running this:
@app.route('/kdef')
def fetch_ergas():
cur = mysql.connection.cursor()
cur.execute("SELECT ergo FROM erga")
rv = list(cur.fetchall())
return '<h2>' + str(rv) + '</h2>'
i get the following results in the browser
[{'ergo': u'52018'}, {'ergo': u'52019'}, {'ergo': u'63096700'}, {'ergo': u'68003400'}, {'ergo': u'68003501'}, {'ergo': u'69003501'}]
I mean it is not an empty cursor