【问题标题】:Error in mysql query using python script使用python脚本查询mysql时出错
【发布时间】:2011-07-27 21:44:47
【问题描述】:

我写了一条指令来使用 2 个 id 从数据库中获取频率,如下所示:

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)

请帮帮我.. 谢谢你.. :)

【问题讨论】:

    标签: python mysql mysql-python


    【解决方案1】:

    如果你想让execute 填写你的调用错误的字符串:

    cursor.execute("select freq from matrix_brown where a_id in (?) and b_id in (?)", (b_item_id,b_after_id))
    

    【讨论】:

    • 很高兴为您提供帮助!如果这为您解决了问题,请接受答案。 :)
    【解决方案2】:
    cursor.execute("select freq from matrix_brown where a_id in (%s) and b_id in (%s)",(b_item_id,b_after_id))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-08
      • 2020-12-02
      • 1970-01-01
      • 2013-03-22
      • 1970-01-01
      • 2014-10-20
      • 2019-04-16
      • 2013-12-16
      相关资源
      最近更新 更多