查看Django ORM 执行的SQL语句

In[2]: from django.contrib.auth.models import User
In[3]: User.objects.all()[0]
Out[3]: <User: root>
In[4]: from django.db import connection
In[5]: connection.queries
Out[5]: 
[{'sql': 'SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" LIMIT 1',
  'time': '0.000'}]
    原文作者:CaiGuangyin
    原文地址: https://www.jianshu.com/p/bdff79ec8ca5
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞