I'm using f notation in a pandas sql query on a postgres database. The following works fine:
areas = pd.read_sql_query(f"SELECT * FROM Areas WHERE dwelling_id={dwelling_id}", con=db.engine)
But when I repeat the same with a different table:
windows = pd.read_sql_query(f"SELECT * FROM Window WHERE area_id={area_id}", con=db.engine)
I get the following error:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) syntax error at or near "Window"
LINE 1: SELECT * FROM Window WHERE area_id=1
^
[SQL: SELECT * FROM Window WHERE area_id=1]
Note that I abandoned the usual params=(variable, ) approach because I couldn't get it to work. Strange that the f notation approach works with the first query but not the second.
Interestingly, I get the same error when I query the windows table in the Heroku app for interograting the database, whereas the other tables do not show the same error:
Can anyone help!

?placeholders with SQLite? PostgreSQL drivers usually use%s— not to be confused with %-formatting strings yourself.text()wrapper that allows using:namedstyle placeholders regardless of the underlying driver.