Answer the question
In order to leave comments, you need to log in
Is there a low-level SQL Query Builder for Python?
You need to write SQL queries that do not fit into the ORM framework.
Writing a query as a string is inconvenient, because it is difficult to modify.
You need something similar, for example, to this
django-query-builder
But this particular thing is not suitable, because it does not support Postgres operators for working with JSON, for example, and others. In general, something more low-level is needed, binding to Django is not required.
All other similar things and ORMs that I looked at all support some minimum number of operators like !=, =, >, < and probably that's all.
Answer the question
In order to leave comments, you need to log in
Here it is written about whether SQL Query Builder is needed .
But in any case, it is desirable to hide the implementation details of creating a request from the client behind the abstract interface responsible for this. In this case, the application will not care what you use there. Personally, I only add a dependency to a new tool when it becomes really necessary.
As Kent Beck said: “Of course, you can do a better job if you have more tools in your toolbox than if you have fewer, but it is much more important to have a handful of tools that you know when not to use, than to know everything about everything and risk using too much solution.”
I usually use this library with Django ORM https://sqlbuilder.readthedocs.io/
There isparser to support JSON statements .
But you can use any query builder that is convenient for you, for example, from SQLAlchemy or Storm ORM, or even LINQ-style https://github.com/pythonql/pythonql . The main thing is to try to avoid the application being aware of implementation details.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question