You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Class to simplify the search for slow and suboptimal sql queries\
39
+
to the database in django projects.
40
+
41
+
---
42
+
43
+
#### About class
44
+
- Class allows you to track any sql queries that are executed inside the body of a loop,
45
+
a decorated function, or a context manager,
46
+
the body can be executed a specified number of times to get the average query execution time.
47
+
48
+
- The class allows you to display formatted output data
49
+
containing brief information about the current iteration of the measurement,
50
+
display sql queries and explain information on them,
51
+
as well as summary information containing data on all measurements.
52
+
53
+
`Do not use the class inside the business logic of your application,
54
+
this will greatly slow down the execution of the queries,
55
+
the class is intended only for the test environment.`
56
+
57
+
---
58
+
59
+
#### - Optional parameters:
60
+
- `assert_q_count`: The expected number of database queries during all `number_runs`, otherwise an exception will be raised: "AssertionError: `N` not less than or equal to `N` queries".
61
+
- `number_runs`: The number of runs of the decorated function or test for loop.
62
+
- `verbose`: Displaying the final results of test measurements within all `number_runs`.
63
+
- `advanced_verb`: Displaying the result of each test measurement.
64
+
- `auto_call_func`: Autorun of the decorated function. (without passing arguments to the function, since the launch takes place inside the class).
65
+
- `queries`: Displaying colored and formatted SQL queries to the database.
66
+
- `explain`: Displaying explain information about each query. (has no effect on the original query).
67
+
- `explain_opts`: Parameters for explain. (for more information about the parameters for explain, see the documentation for your DBMS).
68
+
- `connection`: Connecting to your database, by default: django.db.connection
69
+
70
+
---
71
+
72
+
#### Usage examples::
73
+
74
+
for ctx in CaptureQueries(number_runs=2, advanced_verb=True):
#### Class to simplify the search for slow and suboptimal sql queries\
218
-
to the database in django projects.
219
-
220
-
---
221
-
222
-
#### About class
223
-
- Class allows you to track any sql queries that are executed inside the body of a loop,
224
-
a decorated function, or a context manager,
225
-
the body can be executed a specified number of times to get the average query execution time.
226
-
227
-
- The class allows you to display formatted output data
228
-
containing brief information about the current iteration of the measurement,
229
-
display sql queries and explain information on them,
230
-
as well as summary information containing data on all measurements.
231
-
232
-
`Do not use the class inside the business logic of your application,
233
-
this will greatly slow down the execution of the queries,
234
-
the class is intended only for the test environment.`
235
-
236
-
---
237
-
238
-
#### - Optional parameters:
239
-
- `assert_q_count`: The expected number of database queries during all `number_runs`, otherwise an exception will be raised: "AssertionError: `N` not less than or equal to `N` queries".
240
-
- `number_runs`: The number of runs of the decorated function or test for loop.
241
-
- `verbose`: Displaying the final results of test measurements within all `number_runs`.
242
-
- `advanced_verb`: Displaying the result of each test measurement.
243
-
- `auto_call_func`: Autorun of the decorated function. (without passing arguments to the function, since the launch takes place inside the class).
244
-
- `queries`: Displaying colored and formatted SQL queries to the database.
245
-
- `explain`: Displaying explain information about each query. (has no effect on the original query).
246
-
- `explain_opts`: Parameters for explain. (for more information about the parameters for explain, see the documentation for your DBMS).
247
-
- `connection`: Connecting to your database, by default: django.db.connection
248
-
249
-
---
250
-
251
-
#### Usage examples::
252
-
253
-
for ctx in CaptureQueries(number_runs=2, advanced_verb=True):
0 commit comments