1) You need to setup a database connection pool
2) In the servlet grab a connection and use it like a python db object

This is all psudocode from memory so check it or correct it please

1)  create a module like configuration.py
from MiscUtils.DBPool import DBPool
from pyPgSQL import PgSQL
datapool = DBPool(PgSQL, 5, 'localhost::comsci:aaron:vector5')

#now you have a datapool object that is a pool of connections

2)  In the servlet:
from configuration import datapool

class servlet......

   def writeContent(self):
       conn=datapool.getConnection()
       c=conn.cursor()
       c.execute("Select * from table")
       rs=c.fetchall()
       for row in rs:
            self.writeln("<tr>")
            for field in row:
                self.writeln("<TD>%s</TD>" % field)
            self.writeln("</tr>")
       c.close()

-Aaron

> [EMAIL PROTECTED] wrote:
>> On Tue, 9 Apr 2002 [EMAIL PROTECTED] wrote:
>>
>> > I am writing my own database access at the moment. What
>> sorts of "gotchas"
>> > do I need to worry about? I am a little fuzzy as to how
>> WebKit works and
>> > what issues I face.
>>
>> Do I need to worry about threading issues, etc?
>
> Yes.  WebKit does use multiple threads, so you do have to worry about
> threading issues.  Any given servlet _instance_ is only run in a single
> thread at a time, which works around some, but not all, threading
> issues. But there will be multiple instances of a given servlet class
> running in separate threads.
>
> MiscUtils/DbPool.py provides a database connection pool that is
> designed to work safely in multiple threads.  You'll want to study it
> and possibly use it.
>
> - Geoff
>
> _______________________________________________
> Webware-discuss mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss




_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to