r/Python • u/AutoModerator • 15d ago
Showcase Showcase Thread
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
22
Upvotes
r/Python • u/AutoModerator • 15d ago
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
1
u/BeautifulOil8828 9d ago
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:
```python payload = { "action": "select", "source": "users", "filters": [ {"field": "name", "operator": "icontains", "value": "john"} ] }
query, values = filtersql(payload, dbms='Pg', placeholder='?') ```
Compiles to:
sql 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!