doc/book/en/D020-cookbook.txt
changeset 1675 26f9d2a1a553
parent 1463 136756fff6fb
equal deleted inserted replaced
1674:e4383a510089 1675:26f9d2a1a553
    60                 cursor.execute(update, args)
    60                 cursor.execute(update, args)
    61 
    61 
    62         cnx.commit()
    62         cnx.commit()
    63         cnx.close()
    63         cnx.close()
    64 
    64 
       
    65 
       
    66 * How to load data from a script?
       
    67 
       
    68   The following script aims at loading data within a script assuming pyro-nsd is
       
    69   running and your application is configured with ``pyro-server=yes``, otherwise
       
    70   you would not be able to use dbapi. ::
       
    71 
       
    72     from cubicweb import dbapi
       
    73         
       
    74     cnx = dbapi.connection(database='instance-id', user='admin', password='admin')
       
    75     cur = cnx.cursor()
       
    76     for name in ('Personal', 'Professional', 'Computers'):
       
    77         cur.execute('INSERT Blog B: B name %s', name)
       
    78     cnx.commit()
       
    79 
       
    80