查看Django ORM执行的SQL语句
In [1]: from django.contrib.auth.models import UserIn [2]: User.objects.all()[0]Out[2]:In [3]: from django.db import connectionIn [4]: connection.queriesOut[4]:[{'sql': u'SELECT `au
·
In [1]: from django.contrib.auth.models import User
In [2]: User.objects.all()[0]
Out[2]: <User: admin>
In [3]: from django.db import connection
In [4]: connection.queries
Out[4]:
[{'sql': u'SELECT `auth_user`.`id`, `auth_user`.`username`, `auth_user`.`first_n
ame`, `auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`, `aut
h_user`.`is_staff`, `auth_user`.`is_active`, `auth_user`.`is_superuser`, `auth_u
ser`.`last_login`, `auth_user`.`date_joined` FROM `auth_user` LIMIT 1',
'time': '0.109'}]
In [5]:
In [2]: User.objects.all()[0]
Out[2]: <User: admin>
In [3]: from django.db import connection
In [4]: connection.queries
Out[4]:
[{'sql': u'SELECT `auth_user`.`id`, `auth_user`.`username`, `auth_user`.`first_n
ame`, `auth_user`.`last_name`, `auth_user`.`email`, `auth_user`.`password`, `aut
h_user`.`is_staff`, `auth_user`.`is_active`, `auth_user`.`is_superuser`, `auth_u
ser`.`last_login`, `auth_user`.`date_joined` FROM `auth_user` LIMIT 1',
'time': '0.109'}]
In [5]:
更多推荐
已为社区贡献1条内容
所有评论(0)