Django

Code

Changeset 1306

Show
Ignore:
Timestamp:
11/20/05 11:35:29 (3 years ago)
Author:
adrian
Message:

Small improvement to docs/model-api.txt

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/model-api.txt

    r1305 r1306  
    10801080        return row 
    10811081 
    1082 Note that ``db`` and ``cursor`` simply use the standard `Python DB-API`_. 
    1083  
    1084 If you're not familiar with the Python DB-API, note that the SQL statement in 
     1082If your custom SQL statement alters the data in your database -- for example, 
     1083via a ``DELETE``, ``INSERT`` or ``UPDATE`` -- you'll need to call 
     1084``db.commit()``. example:: 
     1085 
     1086    def my_custom_sql2(self): 
     1087        cursor = db.cursor() 
     1088        cursor.execute("DELETE FROM bar WHERE baz = %s", [self.baz]) 
     1089        db.commit() 
     1090 
     1091``db`` and ``cursor`` simply use the standard `Python DB-API`_. If you're not 
     1092familiar with the Python DB-API, note that the SQL statement in 
    10851093``cursor.execute()`` uses placeholders, ``"%s"``, rather than adding parameters 
    10861094directly within the SQL. If you use this technique, the underlying database