我在这里做错了什么?
i = 0
cursor.execute("insert into core_room (order) values (%i)", (int(i))
错误:
int argument required
数据库字段是 int(11),但我认为 %i 正在生成错误。
更新:
这是一个更彻底的例子:
time = datetime.datetime.now()
floor = 0
i = 0
try: booster_cursor.execute('insert into core_room (extern_id, name, order, unit_id, created, updated) values (%s, %s, %s, %s, %s, %s)', (row[0] , row[0], i, floor, time, time,)) except Exception, e: print e
错误:
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order, unit_id, created, updated) values ('99', '99', '235', '12', '2009-07-24 1' at line 1")