[TransWarp] need a sample PEAK- Form DB connection code
Phillip J. Eby
pje at telecommunity.com
Thu Jun 19 12:58:57 EDT 2003
At 03:45 AM 6/9/03 -0700, spanigrahy at Xanthus.Net wrote:
>Dear Sir,
>
>1)I have successfully installed PEAK latest version.I am looking for a
>sample code of a Form-DB connection using PEAK.The DB used can be
>ZODB/mysql.
PEAK does not currently support MySQL, but it includes example drivers for
Sybase, PostgreSQL, and Gadfly, and you can use the code as an example to
develop drivers of your own.
A simple example of connecting to a database:
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.
>Please help me in this regard.I have gone thru the
>documentation of PEAK from http://peak.telecommunity.com/tut.pdf, it has
>lot of explanation about different API's in peak but it hardly speak any
>examples to test and run those api's. Please help me in getting sample
>codes/examples as to how to run an application in PEAK(python enterprise
>application kit)
As it says in the README file, PEAK is still in a very early stage of
development, and very little documentation or examples exist. I'd suggest
you go back and read this mailing list's archives, as many people have
posted short examples as part of their questions to me, and I have given
them feedback or guidance on improving them.
>2)I have problems in installing ZPattern on Linux.It is looking for a
>Makeup.file.ini but it doesn't comes in python2.2.Please help me in this
>regard.
Check the ZPatterns mailing list archives; I believe this question has been
covered there.
More information about the PEAK
mailing list