[TransWarp] need a sample PEAK- Form DB connection code

Phillip J. Eby pje at telecommunity.com
Mon Jun 23 18:33:01 EDT 2003


Sorry about that.  My mistake; that API was changed in the last couple of 
months.

Note that passing the DB object isn't necessarily what you need to do, 
either.  In essence, you want to pass any component that is in the 
transaction's scope, that does not have a more-local transaction scope 
shadowing it.  Ordinarily, though, you will only ever have one transaction 
scope to worry about.


At 04:15 PM 6/23/03 -0500, darryl wrote:

> >
> > A simple example of connecting to a database:
>
>For the record (so no-one reading the mailing list can get confused as I
>did for a bit) The example as posted here does not work :)
>
>storage.beginTransaction()  <--- requires at least one argument
>
>i would assume you'd pass the db object
>
>storage.beginTransaction(db)
>
>and then subsequently
>
>storage.commitTransaction(db)
>
>
> > from peak.api import config, storage
> >
> > root = config.makeRoot()
> > db =
> > root.lookupComponent('sybase://someLogin:aPasswrord@theServer/dbname')
> >
> > storage.beginTransaction()
> >
> > for row in db('select * from sometable'):
> >      print row
> >
> > storage.commitTransaction()




More information about the PEAK mailing list