1
我使用python 2.7.3和Sqlite3將一些數據保存在一個小數據庫中。我有以下SQL命令:在Sqlite3命令中插入數據庫名稱
thedb = "allpeople"
cursor.execute("INSERT INTO %s VALUES (?,?,?,?,?,?,?,?,?,?,?,?)" % (thedb, data))
conn.commit()
但它拋出以下錯誤:
TypeError: not all arguments converted during string formatting
至少,你應該放一個'%r'而不是'%s',否則如果表名包含特殊字符,你會遇到問題。 – michaelmeyer