Bhuvan raj
Bhuvan raj

Reputation: 413

Error in mysql query using python script

I have wrote an instruction to fetch frequency from database using 2 id's as shown below:

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()

but i'm getting this error :

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 help me out.. Thank you.. :)

Upvotes: 0

Views: 724

Answers (2)

Clodoaldo Neto
Clodoaldo Neto

Reputation: 125244

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

Upvotes: 0

AlG
AlG

Reputation: 15157

If you want execute to fill in the string your calling it wrong:

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

Upvotes: 1

Related Questions