Passing a single argument to
cursor.execute(), or the “missing comma”
The asker is trying to execute SQL with a single placeholder and is passing the argument instead of a 1-tuple of arguments to execute. For example with the
stmt = "SELECT * FROM users WHERE username = %s" username = ('firstname.lastname@example.org') result = cursor.execute(stmt, username)
One way to fix is to add the missing comma in order to turn
username into a tuple:
username = ('email@example.com',)
Any sequence should do, so a list would work as well:
The relevant DB-API v2.0 link.
- Number of MySQL query parameters match arguments passed to execute, but Python raises "not all arguments converted"
- sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 74 supplied
- TypeError: 'int' object does not support indexing
- Python MySQL Connector database query with %s fails
- psycopg2 how deal with TypeError: not all arguments converted during string formatting
- How to create a tuple with only one element