I'd tend to agree with catweazle.
It's entirely possible you want to use
) instead of
], it depends how the MySQLdb library processes the arguments. If it uses string formatting (i.e. the
% operator) then it definitely makes a difference. I would have expected you to see an exception if this was the case, however, similar to the following:
>>> "%s %s %s" % ["one", "two", "three"]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: not enough arguments for format string
>>> "%s %s %s" % ("one", "two", "three")
'one two three'
The reason is simply that string formatting is interpreting the list (created with
]) as a single item to substitute, whereas the tuple (created with
)) is interpreted as a list of parameters. From the official documentation:
If format requires a single argument, values may be a single non-tuple object.  Otherwise, values must be a tuple with exactly the number of items specified by the format string, or a single mapping object (for example, a dictionary).
So, if you pass a list then Python is interpreting that as the single argument case, and it will then probably raise an exception because the format string has three subsititutions but the value list only one.
Of course, I repeat that this is an educated guess about how MySQLdb is working under the hood - it's possible it's a red herring. Definitely worth a try, though.