On Thu, Jan 23, 2014 at 3:33 PM, Rustom Mody <rustompm...@gmail.com> wrote: > On Thursday, January 23, 2014 8:35:58 AM UTC+5:30, Tim Chase wrote: >> On 2014-01-23 03:32, lgabiot wrote: >> > >>>cursor = conn.execute("SELECT filename, filepath FROM files >> > >>>WHERE >> > max_level<(?)", threshold) >> > that doesn't work (throw an exception) > >> That last argument should be a tuple, so unless "threshold" >> is a tuple, you would want to make it > >> sql = "SELECT ... WHERE max_level < ?" >> cursor = conn.execute(sql, (threshold,)) > > Seeing this is becoming a faq I looked at the docs to see if the tuple second > argument could do with some more emphasis > > I think it sure could; see > http://docs.python.org/2/library/sqlite3.html#sqlite3.Cursor > > The builtin connection.execute is even less helpful
I think it's fairly clear from the example that it has to be either a tuple or a dict. Looks fine to me. But I'm sure that, if you come up with better wording, a tracker issue would get the attention it deserves. ChrisA -- https://mail.python.org/mailman/listinfo/python-list