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))