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

darryl developer at csrules.dyndns.org
Mon Jun 23 17:15:39 EDT 2003

> 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


and then subsequently


> 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()
> PEAK can be used to do simple DB processing, but it's usually more
> useful  to create a domain model that describes your application, and
> then create  data managers (typically by subclassing storage.EntityDM)
> to load and save  your objects from the database.

More information about the PEAK mailing list