Last active
July 20, 2022 12:55
-
-
Save yheihei/91e14ddede0da462ed444d288b0d06d5 to your computer and use it in GitHub Desktop.
djangoでsqlの発行数、発行されたsqlをprintする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.db import connection | |
from django.db import reset_queries | |
import json | |
settings.DEBUG = True | |
reset_queries() # クエリのキューを一旦削除 | |
# 調べたい処理をここに書く | |
print(json.dumps(connection.queries, indent=4)) # クエリの文字列 | |
print(len(connection.queries)) # クエリの数 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment