From bce67613cba643a4844dcb879520df3e0e347ff3 Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Thu, 4 Sep 2003 09:26:13 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2262 --- doc/python.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/python.php b/doc/python.php index ad8c6d2651..e97cef3d12 100644 --- a/doc/python.php +++ b/doc/python.php @@ -133,7 +133,7 @@ id; e.g.
   # executes 'select * from project where id=1'.
   # exception is raised if project is not found
-  project_with_id_1 = database.Projects[1]
+  project_with_id_1 = database.Projects[1]
 
Table classes have a find function that builds and executes a @@ -141,17 +141,17 @@ MySQL query based on its arguments:
   # this could return any number (0, 1, 2, ...) of platforms
   # executes 'select * from platform where user_friendly_name="commodore 64"'
-  list_of_platforms_called_c64 = database.Platforms.find(
-      user_friendly_name = 'Commodore 64')
+  list_of_platforms_called_c64 = database.Platforms.find(
+      user_friendly_name = 'Commodore 64')
 
Find can take any number of arguments; they are ANDed. For more advanced usage such as custom SQL queries (anything is possible :) see the pydoc.
-  all_apps = database.Apps.find()
-  finished_yeti_wus = database.Workunits.find(
+  all_apps = database.Apps.find()
+  finished_yeti_wus = database.Workunits.find(
       app = database.Apps.find(name='YETI@home')[0],
-      assimilate_state = ASSIMILATE_DONE)
+      assimilate_state = ASSIMILATE_DONE)
 
Objects (table rows) have their column data as members so you can access and @@ -159,30 +159,30 @@ modify them directly.
   user_quarl = database.users.find(email_addr='quarl@quarl.org')[0]
-  print "name =", user_quarl.name
-  user_quarl.postal_code = 97404
+  print "name =", user_quarl.name
+  user_quarl.postal_code = 97404
 
To create a new database object, create a Python object and give all values as parameters to the initializer:
-  new_app = database.App(name='SPAGHETTI@home',
+  new_app = database.App(name='SPAGHETTI@home',
                          min_version=1,
-                         create_time=time.time())
+                         create_time=time.time())
 
To commit any changes (including a new object), call commit() (the tool boinc/tools/add.py is a command-line interface to this):
-  user_quarl.commit()  # executes an UPDATE
-  new_app.commit()     # executes an INSERT
+  user_quarl.commit()  # executes an UPDATE
+  new_app.commit()     # executes an INSERT
 
To remove an object, call remove():
   team_eric_test = database.Teams(name="Eric's Test Team")[0]
-  team_eric_test.remove()
+  team_eric_test.remove()
   #                        OR
   for team in database.Teams(name="Eric's Test Team"):
       team.remove()
@@ -196,10 +196,10 @@ To access objects related by id, access the field name without "id" suffix:
 column userid)
 
   wu_1234 = database.Workunits.find(name='1234.wu')[0]
-  results_of_wu_1234 = database.Results.find(workunit=wu_1234)
+  results_of_wu_1234 = database.Results.find(workunit=wu_1234)
   for result in results_of_wu_1234:
       os.system("echo 'you are crunching %s' | mail '%s'" %(
-                 result.name, result.host.user.email_addr))
+                 result.name, result.host.user.email_addr))