Skip to content

Settings

In the setting, you can set the threshold and the form of the output.
If you don't set anything up, the default value below will go in.

QUERY_CAPTURE = {
    "PRINT_THRESHOLDS": {  # If you exceed the values below, it will be output to the console.
        "SLOW_MIN_SECOND": 1,  # time thresholds
        "DUPLICATE_MIN_COUNT": 10,  # duplicate query thresholds
        "SIMILAR_MIN_COUNT": 10,  # similar query thresholds
        "COLOR": "yellow",  # The color you want to show when you go over the thresholds.
    },
    "PRESENTER": "django_query_capture.presenter.PrettyPresenter",  # Output class, if you change this class, you can freely customize it.
    "IGNORE_SQL_PATTERNS": [],  # SQL Regex pattern list not to capture
    "PRETTY": {"TABLE_FORMAT": "pretty", "SQL_COLOR_FORMAT": "friendly"},  # Setting values that can be customized when using PrettyPresenter.
}

QUERY_CAPTURE¤

name description available value
PRINT_THRESHOLDS If you exceed the values below, it will be output to the console.
The table below contains additional explanations.
dict
PRESENTER Output class, if you change this class, you can freely customize it. Class that inherited BasePresenter.
Please refer to How to Customize Presenter
IGNORE_SQL_PATTERNS SQL Regex pattern list not to capture list[str]
PRETTY Setting values that can be customized when using PrettyPresenter.
The table below contains additional explanations.
dict
name description available value
SLOW_MIN_SECOND time thresholds ( unit: second ) int
DUPLICATE_MIN_COUNT duplicate query thresholds int
SIMILAR_MIN_COUNT similar query thresholds int
COLOR The color you want to show when you go over the thresholds. Please refer to here for a list of available colors.
Similar vs Duplicate

First, let's define it simply and understand it with one example.
"Similar" has almost the same sql but only different parameters.
"Duplicate" has exactly the same sql.

This example is a "Similar" example.
The preceding SQL is the same, but only the parameters are different.

'INSERT INTO "news_reporter" ("full_name") VALUES (%s)' % ('gil')
'INSERT INTO "news_reporter" ("full_name") VALUES (%s)' % ('young')
'INSERT INTO "news_reporter" ("full_name") VALUES (%s)' % ('ashe')

This example is a "Duplicate" example.
It's exactly the same.

'INSERT INTO "news_reporter" ("full_name") VALUES (%s)' % ('ashe')
'INSERT INTO "news_reporter" ("full_name") VALUES (%s)' % ('ashe')
'INSERT INTO "news_reporter" ("full_name") VALUES (%s)' % ('ashe')

Custom color example

It applies only to table colors.

  • red color_red.png
  • green color_green.png
  • yellow color_yellow.png
  • blue color_blue.png
  • magenta color_magenta.png
  • cyan color_cyan.png
  • white color_white.png

PRETTY¤

name description available value
TABLE_FORMAT You can specify the form of the table. Please refer to this place for the form that can be designated.
SQL_COLOR_FORMAT You can adjust the color format when outputting SQL. Please refer to this place for the form that can be designated.
Custom table format example

All settings can be found here.

  • plain table_plain.png
  • simple table_simple.png
  • github table_github.png
  • grid table_grid.png
  • fancy_grid table_fancy_grid.png
  • presto table_presto.png
  • pretty table_pretty.png
  • psql table_psql.png
  • pipe table_pipe.png
  • orgtbl table_orgtbl.png
Custom sql color format example

All settings can be found here.

  • zenburn sql_zenburn.png
  • material sql_material.png
  • one-dark sql_one_dark.png
  • dracula sql_dracula.png

Last update: January 18, 2022