How do you get persistent database connections with Python?

mark at laptop.local mark at laptop.local
Wed Nov 21 11:37:11 EST 2001


In article <mailman.1005714200.2375.python-list at python.org>,
Gerhard =?iso-8859-1?Q?H=E4ring?=  <gh_pythonlist at gmx.de> wrote:
>On Tue, Nov 13, 2001 at 08:30:51PM -0500, mark at laptop.local wrote:
>> How do you create persistent database connections with Apache, Python, 
>> and PostgreSQL? Any generic methods of creating persistent database connections
>> would be helpful.
>> 
>> I have been trying like crazy to find information on the topic, but I can't
>> find any useful information. 
>> 
>> I am using mod_python and also PyGreSQL modules. I can switch to others
>> if need be.
>
>The db module doesn't matter. What you probably need to check out is the
>Python documenation (wrt. importing modules). Your mod_python handler
>lives as long as the Apache process lives.
>
>So, you just have to instantiate a db connection in the handler's module
>and store the connection object it in the module. That's all there is to
>it.
>

I have been thinking about this. I am just using the normal cgi handler
for mod_python. The docs frown on using the cgi handler, but that is the
easiest thing for me to do. I don't need complicated webpages or any fancy
stuff. Most of my programming has nothing to do with html code, so I don't want
anything fancy. 

So, I guess why question really is, how do I get it to work with the
cgi handler?

Mark




More information about the Python-list mailing list