I'm pretty sure I saw a thread about this, but I can't find it. I need to do something like
query = ((db.mytable.id==somevalue) & (db.mytable.active==True)) if blacklist: query.append(~db.mytable.id.belongs(blacklist)) How do I do this? The reason I'm doing this is psycopg2 raises an exception if the query contains NOT IN().