1

I'm tring to run select query in python where an id = to a number in a variable.

the following statement works from numbers 1 to 9

cur.execute("SELECT ex_id FROM live_orders WHERE lc_id = %s",lc_id)

any number more than or equal to 10 gives the following error

TypeError: not all arguments converted during string formatting

Thanks all.

1 Answer 1

1

You are not passing in a tuple or list. Try this:

cur.execute("SELECT ex_id FROM live_orders WHERE lc_id = %s",[lc_id])

or this:

cur.execute("SELECT ex_id FROM live_orders WHERE lc_id = %s",(lc_id,))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.