vio
vmilitaru at sympatico.ca
Wed Jul 3 17:38:49 EST 2002
* Alain Tesio <alain at onesite.org> [020703 17:11]: > > For instance, I'd be very interested to read in such a tricks and tips list how to avoid the > > overhead of creating a database connection at each call to 'handler'. And so on. > > Just make the connection a global variable. I think I tried that, initialized the db connection at the module level. But somehow my cursor got corrupted, or something. I forgot oracle's error number, only that my workaround was to do something like (we're at module level here): db = DCOracle2.connect(my_login_string) def get_db_cursor(): "create database connection" cursor = db.cursor() # Allocate a cursor return cursor In fact I see that I am re-using the same connection here, so let me re-phrase my initial question: how do I re-use the same *cursor* (or it this a bad idea in the first place). I wonder what would happen in such a multi-threaded environment (well, I'm saling in Linuxland) where multiple httpd instances will hit on the db server (ora8i in my case) with the same cursor *concurrently* (never got to that point of desperation, though - but just from contemplating such possibility sounds like total anarchy). What I did try but eventually got an error on was to re-use the same cursor sequentially (in a non-threaded application). Cheers, Vio
|