Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
f7408b49
Kaydet (Commit)
f7408b49
authored
Nis 25, 2019
tarafından
kingbuzzman
Kaydeden (comit)
Mariusz Felisiak
Nis 29, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #30148 -- Moved logging queries in CursorDebugWrapper to debug_sql() contextmanager.
üst
6754bffa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
utils.py
django/db/backends/utils.py
+20
-21
No files found.
django/db/backends/utils.py
Dosyayı görüntüle @
f7408b49
...
@@ -3,6 +3,7 @@ import decimal
...
@@ -3,6 +3,7 @@ import decimal
import
functools
import
functools
import
hashlib
import
hashlib
import
logging
import
logging
from
contextlib
import
contextmanager
from
time
import
time
from
time
import
time
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -94,40 +95,38 @@ class CursorDebugWrapper(CursorWrapper):
...
@@ -94,40 +95,38 @@ class CursorDebugWrapper(CursorWrapper):
# XXX callproc isn't instrumented at this time.
# XXX callproc isn't instrumented at this time.
def
execute
(
self
,
sql
,
params
=
None
):
def
execute
(
self
,
sql
,
params
=
None
):
start
=
time
()
with
self
.
debug_sql
(
sql
,
params
,
use_last_executed_query
=
True
):
try
:
return
super
()
.
execute
(
sql
,
params
)
return
super
()
.
execute
(
sql
,
params
)
finally
:
stop
=
time
()
duration
=
stop
-
start
sql
=
self
.
db
.
ops
.
last_executed_query
(
self
.
cursor
,
sql
,
params
)
self
.
db
.
queries_log
.
append
({
'sql'
:
sql
,
'time'
:
"
%.3
f"
%
duration
,
})
logger
.
debug
(
'(
%.3
f)
%
s; args=
%
s'
,
duration
,
sql
,
params
,
extra
=
{
'duration'
:
duration
,
'sql'
:
sql
,
'params'
:
params
}
)
def
executemany
(
self
,
sql
,
param_list
):
def
executemany
(
self
,
sql
,
param_list
):
with
self
.
debug_sql
(
sql
,
param_list
,
many
=
True
):
return
super
()
.
executemany
(
sql
,
param_list
)
@contextmanager
def
debug_sql
(
self
,
sql
=
None
,
params
=
None
,
use_last_executed_query
=
False
,
many
=
False
):
start
=
time
()
start
=
time
()
try
:
try
:
return
super
()
.
executemany
(
sql
,
param_list
)
yield
finally
:
finally
:
stop
=
time
()
stop
=
time
()
duration
=
stop
-
start
duration
=
stop
-
start
if
use_last_executed_query
:
sql
=
self
.
db
.
ops
.
last_executed_query
(
self
.
cursor
,
sql
,
params
)
try
:
try
:
times
=
len
(
param_list
)
times
=
len
(
params
)
if
many
else
''
except
TypeError
:
# param_list could be an iterator
except
TypeError
:
# params could be an iterator.
times
=
'?'
times
=
'?'
self
.
db
.
queries_log
.
append
({
self
.
db
.
queries_log
.
append
({
'sql'
:
'
%
s times:
%
s'
%
(
times
,
sql
),
'sql'
:
'
%
s times:
%
s'
%
(
times
,
sql
)
if
many
else
sql
,
'time'
:
"
%.3
f"
%
duration
,
'time'
:
'
%.3
f'
%
duration
,
})
})
logger
.
debug
(
logger
.
debug
(
'(
%.3
f)
%
s; args=
%
s'
,
duration
,
sql
,
param_list
,
'(
%.3
f)
%
s; args=
%
s'
,
extra
=
{
'duration'
:
duration
,
'sql'
:
sql
,
'params'
:
param_list
}
duration
,
sql
,
params
,
extra
=
{
'duration'
:
duration
,
'sql'
:
sql
,
'params'
:
params
},
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment