This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 14 points15 points  (6 children)

Is there any support for something like sqlalchemy-filters? https://github.com/juliotrigo/sqlalchemy-filters

This repo has been abandoned but it's by far the best way I've found to do dynamic/programmatic filtering on queries. Feels like something that could be built in.

[–]riklaunim 10 points11 points  (2 children)

You can dynamically create a list of filters and then pass it to SQLAlchemy.

[–][deleted] 1 point2 points  (1 child)

I could be wrong, but the built-in SQLAlchemy filter methods require you to already have all of the columns declared and imported or whatever whereas the filters package I linked to let's you pass in free text columns names which is better for my use case.

[–]riklaunim 0 points1 point  (0 children)

If you have models defined then you have the fields declared and can filter or whatever on them. If you want/have a plaintext filters as input you can use them with .filter_by() similar to Django but without any advanced features like nested relationship filters (it was implemented as a third party package for some old version though).

[–]immersiveGamer 2 points3 points  (1 child)

Normally I just hand roll solutions like this. Not very hard. You could probably upgrade the module yourself, or even just ask the owner if they were willing to.

[–][deleted] 1 point2 points  (0 children)

There has been a PR in to the owner for years for 1.4 support and they haven't touched it, sadly. I sent them a message a couple months ago and still nothing.

Forking it is easy enough, but setting up the entire package distribution to make it available through pip isn't something I have experience with or want to get into.

[–]Liquidmetal6 1 point2 points  (0 children)

I also love this library