["python","sql","django","shell"]
Get SQL query count during a Django shell session

Is there a way to print the number of raw SQL queries performed by the Django ORM during a Django shell session? This sort of information is already provided by the Django debug toolbar (e.g, 5 QUERIES in 5.83MS but it's not obvious how to get it from the shell.
You can use connection.queries: >>> from django.conf import settings >>> settings.DEBUG = True >>> from django.db import connection >>> Model.objects.count() >>> print(len(connection.queries)) 1