![]() |
Avoid Connecting To MySQL Multiple Times
I have a project of .cgi scripts. This is a quick outline of how the files are being mapped together:
:
index.pyThe problem should be apparent: both the main page and the footer connects to MySQL. How can I save time and use the same connection to MySQL? I don't want to connect twice. And I don't want to remap any of the files, because this way makes most sense for how things need to be pieced together. I have tried: :
Set a global variable in index.py using globals()Therefore the global scope does not get passed into a file that is imported. Your solution? |
Re: Avoid Connecting To MySQL Multiple Times
Is there a way you could have index.py (or an equivalent outermost structure) keep track of the connection and the inner items could query the outer structure for a connection? I haven't used Python much at all, so I don't know if or how that would work out...
|
Re: Avoid Connecting To MySQL Multiple Times
pconnect ('persistent' connect).
Specifics depend on whatever library you happen to be using. |
Re: Avoid Connecting To MySQL Multiple Times
Quote:
Quote:
|
Re: Avoid Connecting To MySQL Multiple Times
Too bad Arevos hasn't been posting lately. I know he'd know the way in a second flat. :icon_smile:
|
| All times are GMT -5. The time now is 3:23 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC