SQLAlchemy EXISTS queryset
I use only django framework with his ORM.
And there is some code:
User.objects.filter(username='test').exists()
that return True or False.
this orm query generate SQL:
SELECT (1) AS "a" FROM开发者_C百科 "auth_user" WHERE "auth_user"."username" = E'test' LIMIT 1
How I can perform equal query in SQLAlchemy?
I try understand this page http://www.sqlalchemy.org/docs/05/ormtutorial.html#using-exists but can't understand how this works.
Help please.
Thanks!
(ret,), = Session.query(exists().where(User.username=='test'))
精彩评论