TypeError: not enough arguments for format string
mysql-python, python, tornado
Solution
Don't pass a tuple of values, pass them as separate arguments.
From the traceback:
query = query % db.literal(args)
Note what's being interpolated in - `args`. Basically, just remove the `()` around the things you were passing in so that they get passed as args instead.
Problem
I'm trying to execute a query with the Tornado's database wrapper, like this - ``` p_id = db.execute_lastrowid("""INSERT INTO `gplaces`.`place` (`gid`, `name`, `reference`, `lat`, `long`, `vicinity`) VALUES (%s, %s, %s, %s, %s, %s)""", ( str(place['id']), str(place['name']), str(place['reference']), float(place['geometry']['location']['lat']), float(place['geometry']['location']['lng']), str(place['vicinity']) ) ) ``` But always getting the error in the title. Here is the traceback - ``` Traceback (most recent call last): File "insertbs.py", line 38, in <module> str(place['vicinity']) File "/home/bibhas/Works/yodl/database.py", line 145, in execute_lastrowid self._execute(cursor, query, parameters) File "/home/bibhas/Works/yodl/database.py", line 207, in _execute return cursor.execute(query, parameters) File "/usr/lib/pymodules/python2.7/MySQLdb/cursors.py", line 159, in execute query = query % db.literal(args) TypeError: not enough arguments for format string ``` Not sure what I'm doing wrong.