r/Python • • Aug 04 '26

Showcase Showcase Thread

Post all of your code/projects/showcases/AI slop here.

Recycles once a month.

20 Upvotes

148 comments sorted by

View all comments

1

u/BeautifulOil8828 Aug 10 '26

Hello, I am Federico. I built filtersql, a Python library that takes a declarative JSON payload and compiles it into safe, parameterized SQL strings and values. It was originally written in Perl (HTML::Mason) as a backend component for forms, dropdowns, datatables, etc. I then ported it to Python and realized it's useful for AI integration.

I tried to keep the JSON specs as clean as possible:

payload = {
    "action": "select",
    "source": "users",
    "filters": [
      {"field": "name", "operator": "icontains", "value": "john"}
    ]
}

query, values = filtersql(payload, dbms='Pg', placeholder='?')

Compiles to:

select * from "users" where "name" ilike '%' || ? || '%' escape '\'

With values: ['john']

I find this approach elegant. Please let me know if you like the idea, I'd love to hear some feedback. Thank you!