# HG changeset patch # User Sandrine Ribeau # Date 1240520755 25200 # Node ID 26f9d2a1a5537447b1b99e2516b468442df03e58 # Parent e4383a5100894df25a946e97c9b5be6b940713b3 [doc] Add script to load data with dbapi using the setting pyro-server=yes. diff -r e4383a510089 -r 26f9d2a1a553 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() + +