我的 Python 脚本有问题,它应该从 MySQL 数据库返回数据。执行查询是
f"select post_date from {table} where date(post_date) >= %s and date(post_date) <= %s order by post_date desc"
但是会产生错误
(1054, "Unknown column 'post*date' in 'field list'")
或
(1064, syntax error... near* ''name_of_database') The problem is with {table}.
如何将表名传输到 sql-query 中?我使用了几种变体:%s、f-strings、.format()、字符串连接('from' + table + 'where...')但它不起作用
附言如果我在 IDE 中运行脚本,则可以正常工作。但是,如果我尝试启动 Flask 应用程序,它会失败