Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下 Python 代码,当我执行它时它给了我错误,错误说
sqlite3.OperationalError:靠近“%”:语法错误
statement = "INSERT INTO %s (%s) VALUES " % (table,columns) + "(%s,%s,%s);" cur.execute(statement, (index,fullpath,filename))
SQL 参数由数据库处理,而不是 Python,因此语法不一定与 Python 相同。
在 SQLite(和大多数其他数据库)中,参数用 标记?:
?
statement = "INSERT INTO %s (%s) VALUES (?,?,?);" % (table,columns) cur.execute(statement, (index,fullpath,filename))