Skip to content

Releases: Friskes/capture-db-queries

Downgrade dependencies

04 Mar 08:23
Compare
Choose a tag to compare
"sqlparse>=0.4.4"
"pygments>=2.17.2"

Add warning for run pytest xdist with capture queries

03 Mar 16:28
Compare
Choose a tag to compare

Added support capture queries in async context

28 Feb 23:06
Compare
Choose a tag to compare
@pytest.mark.asyncio()
@pytest.mark.django_db(transaction=True)
async def test_1(self):
    async with CaptureQueries(number_runs=1, advanced_verb=True) as ctx:
        response = await self.client.get(url)

>>> Queries count: 10  |  Execution time: 0.04s  |  Vendor: sqlite

Redesigned architecture, added the ability to add your own output handlers

01 Dec 13:10
Compare
Choose a tag to compare

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.

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")

Update documentation

27 Nov 18:11
Compare
Choose a tag to compare
v1.2.4

update documentation

Improved logging, coloring of sql queries, and more

27 Nov 14:28
Compare
Choose a tag to compare

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

Swap monotonic to perf_counter timer

23 Nov 13:18
Compare
Choose a tag to compare
v1.2.2

swap monotonic to perf_counter timer

improved display format

23 Nov 13:01
Compare
Choose a tag to compare
v1.2.1

improved display format

Added new parameters, explain and explain_opts to CaptureQueries

22 Nov 22:19
Compare
Choose a tag to compare
# 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

Added warning for use number runs > 1 if use class as context manager

20 Nov 07:24
Compare
Choose a tag to compare