Author: phd
Date: Fri Dec 17 08:17:44 2010
New Revision: 4308
Log:
Documented Update.
Modified:
SQLObject/trunk/docs/SQLBuilder.txt
Modified: SQLObject/trunk/docs/SQLBuilder.txt
==============================================================================
--- SQLObject/trunk/docs/SQLBuilder.txt Thu Dec 16 20:05:14 2010 (r4307)
+++ SQLObject/trunk/docs/SQLBuilder.txt Fri Dec 17 08:17:44 2010 (r4308)
@@ -155,9 +155,9 @@
>> insert = Insert('person', valueList=[('name', 'Test'), ('age', 42)])
# or
>> insert = Insert('person', valueList=[{'name': 'Test'}, {'age': 42}])
+ >> query = connection.sqlrepr(insert)
# Both generate the same query:
# INSERT INTO person (name, age) VALUES ('Test', 42)
- >> query = connection.sqlrepr(insert)
>> connection.query(query)
`values`:
@@ -165,15 +165,38 @@
or `values` must be passed, but not both. Example::
>> insert = Insert('person', values={'name': 'Test', 'age': 42})
+ >> query = connection.sqlrepr(insert)
# The query is the same
# INSERT INTO person (name, age) VALUES ('Test', 42)
- >> query = connection.sqlrepr(insert)
>> connection.query(query)
Instances of the class work fast and thus are suitable for
mass-insertion. If one needs to populate a database with SQLObject
running a lot of INSERT queries this class is the way to go.
+Update
+~~~~~~
+
+A class to build UPDATE queries. Accepts a number of parameters.
+Use connection.query(query) to execute the query.
+
+`table`:
+ A string that names the table to INSERT into.
+
+`values`:
+ A dictionary {key: value}; keys are column names.
+
+`where`:
+ A string or an SQLExpression, represents the WHERE clause.
+
+Example::
+
+ >> update = Update('person',
+ >> values={'name': 'Test', 'age': 42}, where='id=1')
+ >> query = connection.sqlrepr(update)
+ # UPDATE person SET name='Test', age=42 WHERE id=1
+ >> connection.query(query)
+
Nested SQL statements (subqueries)
==================================
|