Sqlalchemy Equivalent Of Django Orm's Relationship-spanning Filter
This example is from the Django documentation. Given the (Django) database model: class Blog(models.Model): name = models.CharField(max_length=100) class Entry(models.Model):
Solution 1:
I also always dreamed of having Django-like "magic joins". I'm familiar with
sqlalchemy-django-query
it, I found that it's not powerful enough for my tasks.
That's why I created https://github.com/absent1706/sqlalchemy-mixins#django-like-queries.
It works similar to sqlalchemy-django-query
but has more additional features (here's a comparison). Also it's well tested and documented.
Solution 2:
How about:
session.query(model.Entry).join((model.Blog, model.Entry.blogid==model.Blog.id)).filter(model.Blog.name=='Beatles Blog').all()
Solution 3:
Already late to the party, but i stumbled across this: https://github.com/mitsuhiko/sqlalchemy-django-query/blob/master/sqlalchemy_django_query.py
This tries to build queries using the django notation.
From the docs: Post.query.filter_by(pub_date__year=2008)
Post a Comment for "Sqlalchemy Equivalent Of Django Orm's Relationship-spanning Filter"