我正试图通过烧瓶的MySQLdb模块执行以下操作:
cur.execute("SELECT post_id FROM tbl_post WHERE post_file_path = '%s'", (_filePath,))然而,我得到了以下错误:
1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'static/uploads/adc67db4-7d23-4bf1-a7ef-7e34dbed246a.jpg''' at line 1"通过命令行查询运行良好,所以我相当肯定这与我提供字符串参数的方式有关。我做错什么了?
发布于 2016-03-30 14:00:42
您不应该引用占位符%s,它是由数据库驱动程序完成的。这应该是可行的:
cur.execute("SELECT post_id FROM tbl_post WHERE post_file_path = %s", (_filePath,))https://stackoverflow.com/questions/36311019
复制相似问题