zinc zinc - 9 months ago 20
MySQL Question

Error in Python: not arguments fully converted during string formatting

My query is:

z = request.session['username']
cursord.execute("delete from table where column = %s",z)


Getting error as not arguments fully converted during string formatting.


query = query % tuple([db.literal(item) for item in args]) TypeError:
not all arguments converted during string formatting "GET /logout/
HTTP/1.1" 500 68562


How to solve this?

Answer Source

You need to pass a tuple:

cursord.execute("delete from table where column = %s", (z,))

If you really are using django, the correct way to logout someone from the session is to use the logout view, as detailed in the documentation.