Capture-db-queries

Latest version: v1.2.5

Safety actively analyzes 688578 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

1.2.5

Customization of the display
> To customize the display of SQL queries, you can import a list with handlers and remove handlers from it or expand it with your own handlers.

python
from capture_db_queries import settings, IHandler

NOTE: The handler must comply with the specified interface.
class SomeHandler(IHandler):
def handle(self, queries_log):
for query in queries_log:
query.sql = "Hello World!"
return queries_log

settings.PRINTER_HANDLERS.remove("capture_db_queries.handlers.ColorizeSqlHandler")
settings.PRINTER_HANDLERS.append("path.to.your.handler.SomeHandler")

1.2.4

1.2.3

Added a logging system
Fixed exception with 0 requests in the body being checked
Added sql coloring
Redesigned logic and added tests

1.2.2

1.2.1

1.2.0

Example of output when using queries and explain:

for _ in CaptureQueries(advanced_verb=True, queries=True, explain=True):
list(Reporter.objects.filter(pk=1))
list(Article.objects.filter(pk=1))

>>> Test №1 | Queries count: 2 | Execution time: 0.22s
>>>
>>>
>>> №[1] time=[0.109] explain=['2 0 0 SEARCH TABLE tests_reporter USING INTEGER PRIMARY KEY (rowid=?)']
>>> SELECT "tests_reporter"."id",
>>> "tests_reporter"."full_name"
>>> FROM "tests_reporter"
>>> WHERE "tests_reporter"."id" = %s
>>>
>>>
>>> №[2] time=[0.109] explain=['2 0 0 SEARCH TABLE tests_article USING INTEGER PRIMARY KEY (rowid=?)']
>>> SELECT "tests_article"."id",
>>> "tests_article"."pub_date",
>>> "tests_article"."headline",
>>> "tests_article"."content",
>>> "tests_article"."reporter_id"
>>> FROM "tests_article"
>>> WHERE "tests_article"."id" = %s
>>>
>>>
>>> Tests count: 1 | Total queries count: 2 | Total execution time: 0.22s | Median time one test is: 0.109s | Vendor: sqlite

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.