[DB-SIG] DCOracle2 excepting after execute

Kancianic, Jennifer C. (JKANCIAN) JKANCIAN at arinc.com
Thu Jun 12 11:04:14 EDT 2003

Yes - thanks - we use Oracle 8.1.7.

Here is some more code.  This updates the timestamp on a session key
generated by webkit:

def updateLastAccessed(self, key):
            sql = '''UPDATE sessions SET last_accessed = SYSDATE WHERE id =
            results = self.db.doSQL(sql, (key, ))                   
            self.log.exception("updateLastAccessed failed for session key "
+ key)

def doSQL(self, sqlStatement, list=(), noPrefetch=FALSE):
        """Inserts into the database with the given SQL statement if
        select flag == 0, othwerwise, performs the given select
        sqlStatement = sqlStatement.strip()

            if (not sqlStatement.upper().startswith('SELECT')):
                if (len(list) > 0) and (type(list[0]) == type((1, 2))):
                    return self.cursor.executemany(sqlStatement, list)
                self.cursor.execute(sqlStatement, list)

            if sqlStatement.upper().startswith('SELECT'):
                newconn = self._pool.getConnection()
                cursor = newconn.cursor()
                if (noPrefetch):
		    # DB-SIG - This next statement is where the problem
                cursor.execute(sqlStatement, list)
                returnVal = (self.fetchrows(cursor) or [])
                return returnVal

        except DCOracle2.Error, e:
            if sqlStatement.upper().startswith('SELECT'):
            self.handleError(sqlStatement, str(e))

When I execute the update statement at the sqlplus command line, it tells me
that one row is updated.  I have thus far been unable to make the problem
happen in our development and test environments.  It happens in production
regularly (not EVERY time).  In particular, there are three different
update/insert scenarios where it happens more often.


-----Original Message-----
From: Andy Todd [mailto:andy47 at halfcooked.com]
Sent: Thursday, June 12, 2003 4:51 AM
To: Kancianic, Jennifer C. (JKANCIAN)
Cc: 'db-sig at python.org'
Subject: Re: [DB-SIG] DCOracle2 excepting after execute

Kancianic, Jennifer C. (JKANCIAN) wrote:

> Sometimes, when our code executes an update or insert statement, DCOracle2
> will except unexpectedly.  Here is the traceback from our logfile:
> Traceback (most recent call last):
>   File "/home/adc/adc/lib/UserDB.py", line 414, in updateLastAccessed
>     results = self.db.doSQL(sql, (key, ))
>   File "/home/adc/adc/lib/OracleDB.py", line 111, in doSQL
>     self.cursor.execute(sqlStatement, list)
>   File "/usr/local/lib/python2.2/site-packages/DCOracle2/DCOracle2.py",
> 1008, in execute
>     self.rowcount = self._cursor.rowcount()
> AttributeError: 'NoneType' object has no attribute 'rowcount'
> This appears to be occurring in the DCOracle2 code that tries to get the
> number of rows affected after the execution.
>         result = self._cursor.execute()
>         if result in RowCountResults:
>             self.rowcount = self._cursor.rowcount()
>         else:
>             self.rowcount = -1
> Has anyone encountered this?  What can I do anything to NOT get the
> exception?  This is happening regularly and is not good.
> If this was designed this way, how should I deal with it?  Forgive my
> ignorance.
> I am using Oracle 1.8, Linux Redhat 7.1, python 2.2, DCOracle 1.3 (I
> Thanks for your help,
> Jenny
> _______________________________________________
> DB-SIG maillist  -  DB-SIG at python.org
> http://mail.python.org/mailman/listinfo/db-sig

It possibly is a bug, but it is a little hard to tell without looking at 
all of the code. Can you produce a nice simple example that causes the 
same exception to be raised? Or can you strip the SQL from the your 
example and tell us what happens when you run it in SQL*Plus?

I haven't come across a situation where a DCOracle2 cursor object 
doesn't have a rowcount attribute, but that may just be me. Also, are 
you sure about the versions of the software you are using? Oracle 
doesn't currently ship a version 1.8, is it perhaps 8.1?

 From the desk of Andrew J Todd esq - http://www.halfcooked.com/

More information about the DB-SIG mailing list