In message , Mitchell L
Model wrote:
> 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.
In SQL, NULL is
Mitchell L Model wrote:
def lookupxy(x, y):
if y:
conn.execute("SELECT * FROM table WHERE COL1 = ? AND COL2 = ?",
(x, y))
else:
conn.execute("SELECT * FROM table WHERE COL1 = ? AND COL2 IS NULL",
(x,))
Erratum:
please read 'if y is *not* None:'. (think that if y = 0, you won't
execute the proper code block with 'if y:').
JM
Jean-Michel Pichavant wrote:
I fall into the same issue when using postgres. Your main concern is
that NULL = NULL will return False. Could seems strange but it has
mu
I fall into the same issue when using postgres. Your main concern is
that NULL = NULL will return False. Could seems strange but it has much
advantages sometimes, however this is not the purpose.
I found your solution quite acceptable. Just replace 'if y:' by 'if y is
None:', add a comment to po
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
> re
On May 20, 10:54 am, MRAB wrote:
> 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
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 fo