[SQL-CVS] r4548 - SQLObject/branches/1.2/docs
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2012-10-06 16:07:24
|
Author: phd Date: Sat Oct 6 09:24:46 2012 New Revision: 4548 Log: Neil Muller fixed most of the doctests. Modified: SQLObject/branches/1.2/docs/SQLObject.txt Modified: SQLObject/branches/1.2/docs/SQLObject.txt ============================================================================== --- SQLObject/branches/1.2/docs/SQLObject.txt Sun Jun 24 06:19:26 2012 (r4547) +++ SQLObject/branches/1.2/docs/SQLObject.txt Sat Oct 6 09:24:46 2012 (r4548) @@ -212,6 +212,7 @@ Now we'll create the table in the database:: >>> Person.createTable() + [] We can change the type of the various columns by using something other than `StringCol`, or using different arguments. More about this in @@ -302,13 +303,16 @@ >>> Person._connection.debug = True >>> p = Person(firstName='Bob', lastName='Hope') 1/QueryIns: INSERT INTO person (last_name, middle_initial, first_name) VALUES ('Hope', NULL, 'Bob') + 1/QueryR : INSERT INTO person (last_name, middle_initial, first_name) VALUES ('Hope', NULL, 'Bob') 1/COMMIT : auto - 1/QueryOne: SELECT first_name, middle_initial, last_name FROM person WHERE id = 2 + 1/QueryOne: SELECT first_name, middle_initial, last_name FROM person WHERE ((person.id) = (2)) + 1/QueryR : SELECT first_name, middle_initial, last_name FROM person WHERE ((person.id) = (2)) 1/COMMIT : auto >>> p <Person 2 firstName='Bob' middleInitial=None lastName='Hope'> >>> p.middleInitial = 'Q' - 1/Query : UPDATE person SET middle_initial = 'Q' WHERE id = 2 + 1/Query : UPDATE person SET middle_initial = ('Q') WHERE id = (2) + 1/QueryR : UPDATE person SET middle_initial = ('Q') WHERE id = (2) 1/COMMIT : auto >>> p2 = Person.get(1) >>> # Note: no database access, since we're just grabbing the same @@ -347,7 +351,8 @@ >>> Person._connection.debug = True >>> peeps = Person.select(Person.q.firstName=="John") >>> list(peeps) - 1/Select : SELECT person.id, person.first_name, person.middle_initial, person.last_name FROM person WHERE (person.first_name = 'John') + 1/Select : SELECT person.id, person.first_name, person.middle_initial, person.last_name FROM person WHERE ((person.first_name) = ('John')) + 1/QueryR : SELECT person.id, person.first_name, person.middle_initial, person.last_name FROM person WHERE ((person.first_name) = ('John')) 1/COMMIT : auto [<Person 1 firstName='John' middleInitial='Q' lastName='Doe'>] @@ -368,6 +373,7 @@ statements with these it'll give you the SQL for that statement. You can also create your SQL more manually:: + >>> Person._connection.debug = False # Needed for doctests >>> peeps = Person.select("""address.person_id = person.id AND ... address.zip LIKE '504%'""", ... clauseTables=['address']) @@ -523,6 +529,7 @@ ... zip = StringCol(length=9) ... person = ForeignKey('Person') >>> Address.createTable() + [] Note the column ``person = ForeignKey("Person")``. This is a reference to a `Person` object. We refer to other classes by name @@ -611,7 +618,9 @@ ... users = RelatedJoin('User') >>> User.createTable() + [] >>> Role.createTable() + [] .. note:: |