How to pass table name in read_sql_query

Solution 1:

You need to change this:

sq = "SELECT * FROM {}"

to this:

sq = "SELECT * FROM `{}`"

If you don't, the table name won't be quoted, and it will only associate the first word of "Site Visit Fees-Zero Amount" with the table name, leaving it with extra words. That causes a syntax error.

As a side note, you may want to consider not using spaces inside your table names.