English 中文(简体)
Django DB联线:是圆射物阵列还是仅指参考?
原标题:Django DB connection: is query object array or only reference?

我要说的是,我有以下法典:

obj = MyUser.objects.get(pk=1)

name = obj.name
age = obj.age
email = obj.email
phone = obj.phone
city = obj.city

因此,我有<编码>obj。 这个阵列是否含有关于我的“我的”物体的所有信息,还是只是一个参考点?

I m 有趣的是name = obj.name 首次向亚洲开发银行提出请求,

age = obj.age向亚洲开发银行发出第二次请求,

email = obj.email sent third request to DB,

phone = obj.phone sent the fourth request to DB,

city = obj.city 向非行发出第五次请求

or there is only one request, when obj = MyUser.objects.get(pk=1).

这并不影响系统的业绩,因此,它是一个非常有趣的问题。

感谢!

最佳回答

它既不是:它是一个标的,其价值在数据库瞬时即从数据库中初步确定。 违约后,Django为整个行各业选取,并使用一栏数值对物体进行即时。

你们描述的方式是很奇怪的,效率极低。 如果有人问问问问问,会发生什么? 每一行各列一栏?

当然,你只能要求使用<条码>价值<>/条码>或<条码>价值_list/code>的某些栏目,仅仅通过使用<条码> ffer或<条码>获取与某些推迟的领域有关的物体。

请注意,你可以询问Django的所作所为——在炮弹中,是行不通的。

from django.db import connection
print connection.queries

这份清单将给你一份截至该日期的所有问询清单。

问题回答

暂无回答




相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签