Search code examples
pythonhtmlmysqlflaskpymysql

Python/Flask query returning empty table with correct number of cells


I'm doing this python flask project.

When I'm executing a query, the resulting webpage shows the resulting table with the correct number of rows and columns and cells but all the cells are empty.

[removed code]


Solution

  • By requesting DictCursor as you are, it seems the results should be coming as dicts keyed by table column names, as in the test cases at the top of the file here: https://github.com/PyMySQL/PyMySQL/blob/main/pymysql/tests/test_DictCursor.py

    In that case you need to change your accessors from indexes to column names, e.g. {{item[0]}} to {{item['colname']}}.