Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7853087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:34:43+00:00 2026-06-02T19:34:43+00:00

I’m working on an application that does reporting-type things, and I often need to

  • 0

I’m working on an application that does reporting-type things, and I often need to take a filter specified with JSON, convert that to an SQLAlchemy query, then send the results back to the browser (for example the filter start_date: 1234, end_date: 5678, widget_ids: [1, 2, 3] needs to be converted into the query … WHERE start_date >= 1234 AND end_date <= 5678 AND widget_id in (1, 2, 3)).

Is there a tool which will do this kind of conversion automatically (for example, using suffixes like Django’s ORM: start_date__ge: 1234, end_date__le: 5678, widget_id__in: [1, 2, 3])?

Obviously there would be security and performance implications of such a scheme… But I’d like to know if anything like this exists before I build one myself.

Edit: I realize that I could build my own thing, but I’m specifically wondering if there are existing tools/libraries, so I don’t need to re-invent the wheel.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:34:46+00:00Added an answer on June 2, 2026 at 7:34 pm

    I have some simple code that may be of interest (source):

    def create_attr_filter(request, mapped_class):
        """Create an ``and_`` SQLAlchemy filter (a ClauseList object) based
        on the request params (``queryable``, ``eq``, ``ne``, ...).
    
        Arguments:
    
        request
            the request.
    
        mapped_class
            the SQLAlchemy mapped class.
        """
    
        mapping = {
            'eq'   : '__eq__',
            'ne'   : '__ne__',
            'lt'   : '__lt__',
            'lte'  : '__le__',
            'gt'   : '__gt__',
            'gte'  : '__ge__',
            'like' : 'like',
            'ilike': 'ilike'
        }
        filters = []
        if 'queryable' in request.params:
            queryable = request.params['queryable'].split(',')
            for k in request.params:
                if len(request.params[k]) <= 0 or '__' not in k:
                    continue
                col, op = k.split("__")
                if col not in queryable or op not in mapping.keys():
                    continue
                column = getattr(mapped_class, col)
                f = getattr(column, mapping[op])(request.params[k])
                filters.append(f)
        return and_(*filters) if len(filters) > 0 else None
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.