[doc] Add script to load data with dbapi using the setting pyro-server=yes.
authorSandrine Ribeau <sandrine.ribeau@logilab.fr>
Thu, 23 Apr 2009 14:05:55 -0700
changeset 1675 26f9d2a1a553
parent 1674 e4383a510089
child 1676 543de6c7f0da
[doc] Add script to load data with dbapi using the setting pyro-server=yes.
doc/book/en/D020-cookbook.txt
--- a/doc/book/en/D020-cookbook.txt	Thu Apr 23 13:46:57 2009 -0700
+++ b/doc/book/en/D020-cookbook.txt	Thu Apr 23 14:05:55 2009 -0700
@@ -62,3 +62,19 @@
         cnx.commit()
         cnx.close()
 
+
+* How to load data from a script?
+
+  The following script aims at loading data within a script assuming pyro-nsd is
+  running and your application is configured with ``pyro-server=yes``, otherwise
+  you would not be able to use dbapi. ::
+
+    from cubicweb import dbapi
+        
+    cnx = dbapi.connection(database='instance-id', user='admin', password='admin')
+    cur = cnx.cursor()
+    for name in ('Personal', 'Professional', 'Computers'):
+        cur.execute('INSERT Blog B: B name %s', name)
+    cnx.commit()
+
+