Capitalize SQL keywords
This commit is contained in:
parent
cb844497d0
commit
6dfd02f88c
|
@ -105,13 +105,13 @@ Index lookups
|
||||||
``raw()`` supports indexing, so if you need only the first result you can
|
``raw()`` supports indexing, so if you need only the first result you can
|
||||||
write::
|
write::
|
||||||
|
|
||||||
>>> first_person = Person.objects.raw('SELECT * from myapp_person')[0]
|
>>> first_person = Person.objects.raw('SELECT * FROM myapp_person')[0]
|
||||||
|
|
||||||
However, the indexing and slicing are not performed at the database level. If
|
However, the indexing and slicing are not performed at the database level. If
|
||||||
you have a large number of ``Person`` objects in your database, it is more
|
you have a large number of ``Person`` objects in your database, it is more
|
||||||
efficient to limit the query at the SQL level::
|
efficient to limit the query at the SQL level::
|
||||||
|
|
||||||
>>> first_person = Person.objects.raw('SELECT * from myapp_person LIMIT 1')[0]
|
>>> first_person = Person.objects.raw('SELECT * FROM myapp_person LIMIT 1')[0]
|
||||||
|
|
||||||
Deferring model fields
|
Deferring model fields
|
||||||
----------------------
|
----------------------
|
||||||
|
@ -274,11 +274,11 @@ names, which means you end up with a ``list`` of values, rather than a
|
||||||
|
|
||||||
Here is an example of the difference between the two::
|
Here is an example of the difference between the two::
|
||||||
|
|
||||||
>>> cursor.execute("SELECT id, parent_id from test LIMIT 2");
|
>>> cursor.execute("SELECT id, parent_id FROM test LIMIT 2");
|
||||||
>>> cursor.fetchall()
|
>>> cursor.fetchall()
|
||||||
((54360982L, None), (54360880L, None))
|
((54360982L, None), (54360880L, None))
|
||||||
|
|
||||||
>>> cursor.execute("SELECT id, parent_id from test LIMIT 2");
|
>>> cursor.execute("SELECT id, parent_id FROM test LIMIT 2");
|
||||||
>>> dictfetchall(cursor)
|
>>> dictfetchall(cursor)
|
||||||
[{'parent_id': None, 'id': 54360982L}, {'parent_id': None, 'id': 54360880L}]
|
[{'parent_id': None, 'id': 54360982L}, {'parent_id': None, 'id': 54360880L}]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue