S
S
Sergey Eremin2014-12-08 23:28:50
Django
Sergey Eremin, 2014-12-08 23:28:50

Are there any Python/Django libraries for organizing a SQL query inside a ready-made QuerySet?

In a past life, I dealt with ColdFusion (CFML) and I really liked the ability to make a SQL query into a ready-made CFQUERY (I think it was available from version 4.5). What is it? Nothing complicated: you make some heavy query into the database (with joining tables, groupings, etc.); and in the received answer-table you build one more (or more than one) SQL query as needed. This approach made it possible to significantly reduce the load on the base, because. to organize some additional sorting (including by calculated fields), finding max and min, or small SQL calculations, you didn’t have to pull the database with your heavy queries ... And CFQUERY still hangs in memory (after all, the application needs to receive records and fields from it), why not ask him to sort something.
Actually, I want to find something similar for Django. In the application, you need to first find the maximum in one field, in bulk in another, then take the second after the maximum entry in the third field ... SQL-query to the cached table is a nice thing for this! Is there such a thing in Python/Django?
PS With the help of built-in procedures in some databases, this can be organized (in the sense of reducing the load on the database), but it is important for me to do without using built-in procedures.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bromzh, 2014-12-10
@Sergei_Erjemin

Look towards SQLAlchemy. It consists of 2 parts: the core and a separate ORM. You don't need ORM, you can use only the main part. And alchemy will have more opportunities than Dzhang's ORM.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question