Re: Exception exceptions.AttributeError - Depending upon the naming of the module ( connector.py / error_connector.py)

"M.-A. Lemburg" <[email protected]>
Newsgroups gmane.comp.python.egenix.user
Organization eGenix.com Software GmbH
Message-ID <[email protected]>
On 2009-02-11 14:24, M.-A. Lemburg wrote:
> On 2009-02-11 13:14, Senthil Kumaran wrote:
> Here's a typical example of how you'd use mxODBC Connect:
> 
> from mx.ODBCConnect.Client import ServerSession
> 
> def main():
> 
>     # Setup a server session
>     session = ServerSession(config_file='client-config.ini')
> 
>     # Connect to the mxODBC Connect Server
>     db_api = session.open()
> 
>     # Connect to a database
>     connection = db_api.DriverConnect('DSN=...;UID=...;PWD=...')
> 
>     # Process data on the connection
>     ...
> 
>     # Finalize the connection
>     connection.close()
> 
>     # Finalize the server session
>     session.close()
> 
> Note that there are no module global being used. This assures that
> you have controlled garbage collection.

Here's an easy fix for the situation where you have the session
object defined as module global:

# Register atexit function
import atexit
atexit.register(session.close)

Such exit functions are called at Python shutdown time, but just
before the interpreter gets finalized, ie. all modules are still
available, so all the connections of the session get closed properly.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Feb 11 2009)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/


_______________________________________________________________________
eGenix.com User Mailing List                     http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.