Haven’t seen a mention in readme, but I’ve found in the sources some nicety for INSERT/VALUES too!
It's a small app with an attempt (and a goal) to model persistence without ORM. I think it suits quite well, could be fully type hinted (with some raw force though) and somewhat less verbose in this particular context.
But also I see how it could be a maintenance hell for a medium/large scale apps.
Also, haven’t seen how sqlbind handles optional JOINs and especially optional LATERAL.
from sqlbind import WHERE, FIELDS, join_fragments
q = Q() # a QueryParams factory
fields = []
joins = []
filters = []
if some_condition:
fields.append('sub_table.field')
joins.append('INNER JOIN sub_table ON (subid)')
filters.append(q.sub_table.date > since)
sql = f'''\
SELECT {FIELDS('table.field', *fields)}
FROM table
{join_fragments(' ', joins)}
{WHERE(*filters)}
'''
Personally I prefer this explicitness to ORM for complex queries which include recursive or multiple joins to the same table.But I agree ORM shines with simple joins especially if models include proper relationship and there is no need to specify 'ON' condition every time.
Should be much easier now with LLMs, though :)