I have the following code:
s = select([user.c.Title]).where(user.c.Action != 'delete')
conn = engine.connect()
rows = conn.execute(s).fetchall()
print rows
conn.close()
The code is supposed to fetch a list of titles where the column 'Action' is not equal to 'delete'. Everytime I run the code, I get back an empty list. The output in the console with echo set to True is:
2014-08-05 16:27:31,492 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2014-08-05 16:27:31,492 INFO sqlalchemy.engine.base.Engine ()
2014-08-05 16:27:31,492 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2014-08-05 16:27:31,492 INFO sqlalchemy.engine.base.Engine ()
2014-08-05 16:27:31,493 INFO sqlalchemy.engine.base.Engine SELECT "Notes"."Title"
FROM "Notes"
WHERE "Notes"."Action" != ?
2014-08-05 16:27:31,493 INFO sqlalchemy.engine.base.Engine ('delete',)
[]
I checked the database and there are rows which exist which do not have 'delete' in the 'Action' column.
When I use:
s = select([user.c.Title]).where(not_(user.c.Action != 'delete'))
I still get the same output.
Thanks in advance!