-1

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]

1
  • 1
    1) SELECT * ... is not a good idea. The output of * can change under you. 2) What does pymysql.cursors.DictCursor actually return? Is it like in psycopg2 where it can be accessed via indexing or via keys? 3) Is cursor.fetchall() actually returning anything? Commented May 2, 2022 at 23:06

1 Answer 1

1

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']}}.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I used some starter code without realizing exactly what it was doing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.