summaryrefslogtreecommitdiff
path: root/docs/model-api.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-20 17:35:29 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-20 17:35:29 +0000
commitc472b1471d662b3a3f35641b83086622eae3c10e (patch)
tree59d7c5e8317d62b69a5669ec58ffcdb2fbe7f182 /docs/model-api.txt
parent2bb18eddbe6f5ea4e46da330a25a2918b1ca6dc5 (diff)
Small improvement to docs/model-api.txt
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1306 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/model-api.txt')
-rw-r--r--docs/model-api.txt12
1 files changed, 10 insertions, 2 deletions
diff --git a/docs/model-api.txt b/docs/model-api.txt
index 3ef6e9803e..d8cc33ba87 100644
--- a/docs/model-api.txt
+++ b/docs/model-api.txt
@@ -1079,9 +1079,17 @@ the resulting rows. Example::
row = cursor.fetchone()
return row
-Note that ``db`` and ``cursor`` simply use the standard `Python DB-API`_.
+If your custom SQL statement alters the data in your database -- for example,
+via a ``DELETE``, ``INSERT`` or ``UPDATE`` -- you'll need to call
+``db.commit()``. example::
-If you're not familiar with the Python DB-API, note that the SQL statement in
+ def my_custom_sql2(self):
+ cursor = db.cursor()
+ cursor.execute("DELETE FROM bar WHERE baz = %s", [self.baz])
+ db.commit()
+
+``db`` and ``cursor`` simply use the standard `Python DB-API`_. If you're not
+familiar with the Python DB-API, note that the SQL statement in
``cursor.execute()`` uses placeholders, ``"%s"``, rather than adding parameters
directly within the SQL. If you use this technique, the underlying database
library will automatically add quotes and escaping to your parameter(s) as