[Tutor] The case of the missing close

Robert, Andrew ARobert at MFS.com
Wed Dec 1 13:59:28 CET 2004

Hi Kent,

That's great.

I tried the code changes you mentioned but am now running into an error
with the cx_Oracle module.

I get the message  

Traceback (most recent call last):
  File "C:\python_code\oracle\maestrodev_oracle_connector.py", line 34,
in ?
    dbobj = db_utils.db('maestro_d','MAESTRO_OWNER','joecool')
  File "C:\python_code\oracle\db_utils.py", line 9, in __init__
    class db:
NameError: global name 'cx_Oracle' is not defined

The main script imports this module on load so I am a little confused as
to why it is balking.

Any thoughts?

Thank you,
Andrew Robert
Systems Architect
Information Technology - OpenVMS
Massachusetts Financial Services
Phone:  617-954-5882
Pager:   781-764-7321
E-mail:  arobert at mfs.com
Linux User Number: #201204

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
Behalf Of Kent Johnson
Sent: Wednesday, December 01, 2004 7:53 AM
To: tutor at python.org
Subject: Re: [Tutor] The case of the missing close

Kent Johnson wrote:
> Here is a sketch to get you started. I'm not sure how cursors work so
> may be off the mark! You may want to keep the cursor as an attribute
> db so you can reuse it?
> class db:
>   def __init__(self, db, uname, passwd)
>     self.connection =
>   def execute(self, sql):
>     cursor = connection.cursor()

should be
     cursor = self.connection.cursor()

>     cursor.execute(sql)
>     return cursor
>   def close(self):
>     self.connection.close()
>     self.connection = None # Prevent reusing a closed connection
Tutor maillist  -  Tutor at python.org

"MFS Relay Service" made the following
 annotations on 12/01/2004 08:05:08 AM
This email communication and any attachments may contain proprietary, confidential, or privileged information.  If you are not the intended recipient, you are hereby notified that you have received this email in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited.  The sender does not waive confidentiality or any privilege by mistransmission.  If you have received this email in error, please notify the sender immediately, delete this email, and destroy all copies and any attachments.

More information about the Tutor mailing list