import MySQLdb
import random
db = MySQLdb.connect (host = "localhost", user = "python-test", passwd = "python", db = "python-test")
cursor = db.cursor()
var = .3
sql = "INSERT INTO RandomInt
(RAND)
VALUES
(var)" # RandomInt is the name of the table and Rand is the Column Name
cursor.execute(sql)
db.commit()
db.close()
我收到一条错误消息,提示Operational Error: (1054, "Unknown column 'var' in 'field list'")
为什么我会收到此错误以及如何解决此问题,尽管我已经定义了 var?