in reply to Using DBI handle in several packages
Personally what I would do is have a single module that connects to the database, caches the handle, and returns it. Every other module just asks the single module to give them the appropriate connection, and gets it without worrying about whether a connect just happened or not. Then each module just has to never close it, and not leave any state.
State you ask? Well yes. For instance if you create #tables in Sybase (ie connection-specific temporary tables) you should also delete them when you are done. To be sure that that kind of state is properly cleaned up what you can do is have the functions that create state use ReleaseAction to make sure that the state will be cleaned up appropriately.
Of course that assumes that the authors of the modules can hold to a reasonable standard. To quote Larry Wall, Give people enough rope to hang themselves, and they'll usually figure out how not to, after several successes. It is your decision whether the people writing those modules have had enough successes already...
|
|---|