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,))

The more question marks involved the more complicated this would get, especially if question marks in the middle of several would sometimes need to be NULL.


With SQLAlchemy you could write:

table.select().where((table.c.col1==x) & (table.c.col2==y))

where x or y are None, the sql engine generates the appropriate "IS NULL" clause.


I hope I'm missing something and that someone can tell me what it is.


Yes, you are missing SQLAlchemy ;)
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to