Conrad Steenberg
conrad at hep.caltech.edu
Thu Aug 7 08:36:30 EST 2003
Hi Van Doing it the way you describe would work, but depending on the DB and Apache settings, you might have more Apache processes spawned than the number of connections your DB can handle. Using dbpool would make your web app fail more gracefully, i.e. get slower with more connections, instead of giving some users an error that it was unable to connect to the DB, as you often see on overloaded discussion sites. Cheers Conrad On Thu, 2003-08-07 at 08:04, VanL wrote: > Hello, > > I am using quixote+mod_python as a front-end for a database app. Based > on the example in the faq, it looks like I could just make the > connection in a separate module and mod_python would automatically make > the database connections persist. > > For example, > > if I have code that is run by mod_python > > === persistdb.py ================== > import psycopg as db > def connect(): > global connection > try: > conn = connection > return conn > except NameError: > connection = db.connect(connection_string) > return connection > > === application.py ================== > import persistdb > conn = persistdb.connect() > # Use conn here > > From the FAQ, it appears that the db connection "connection" would > persist transparently. Is this a correct understanding? > If that is true, would there be any benefit to using dbpool, as opposed > to the code posted above? > > Thanks, > > VanL > > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python --
|