错误MySQL查询使用python脚本
问题描述:
我已经写来从使用2级的数据库频率的指令,如下图所示:错误MySQL查询使用python脚本
cursor = db.cursor()
cursor.execute("select freq from matrix_brown where a_id in (%s) and b_id in (%s)",b_item_id,b_after_id)
b_freq=cursor.fetchone()
但我得到这个错误:
cursor.execute("select freq from matrix_brown where a_id in (%s) and b_id in (%s)",b_before_id,b_item_id)
TypeError: execute() takes at most 3 arguments (4 given)
PLS帮我.. 谢谢.. :)
答
如果你想execute填写您的调用是错误的字符串:
cursor.execute("select freq from matrix_brown where a_id in (?) and b_id in (?)", (b_item_id,b_after_id))
答
cursor.execute("select freq from matrix_brown where a_id in (%s) and b_id in (%s)",(b_item_id,b_after_id))
很高兴能帮到你!如果这解决了你的问题,请接受答案。 :) – AlG 2011-04-01 19:37:18