sqlite3, qmarks, and NULL values
MRAB
google at mrabarnett.plus.com
Tue May 19 20:54:08 EDT 2009
Mitchell L Model wrote:
> Suppose I have a simple query in sqlite3 in a function:
>
> def lookupxy(x, y):
> conn.execute("SELECT * FROM table WHERE COL1 = ? AND COL2 = ?",
> (x, y))
>
> However, COL2 might be NULL. I can't figure out a value for y that would retrieve rows for which COL2 is NULL. It seems to me that I have to perform an awkward test to determine whether to execute a query with one question mark or two.
>
[snip]
Have you tried None, ie lookupxy(x, None)?
More information about the Python-list
mailing list