Nested Looping SQL Querys

Carsten Haese carsten at uniqsys.com
Thu Sep 21 09:08:59 EDT 2006


On Thu, 2006-09-21 at 01:12, Dennis Lee Bieber wrote:
> On Wed, 20 Sep 2006 13:21:54 -0400, Steve Holden <steve at holdenweb.com>
> declaimed the following in comp.lang.python:
> 
> > .execute() is a cursor method, not a connection method. Some DB API 
> > modules do implement it as a connection method, but that makes it 
> > impossible for several cursors to share the same connection (which is 
> > allowed by some modules).
> >
> 	It struck me that the original wasn't using a cursor just after the
> messages posted.

It doesn't look like the OP is using anything even remotely DB-API
compliant:

"""
import cmi
<snip>
import hermes
conn = hermes.db()
<snip>

pubID=cgiForm.getvalue('pubID')
pubName=cgiForm.getvalue('pubName','Unknown Publication')

sqlcheck1 = "SELECT pub_type FROM medusa.cmi_publication WHERE pub_id =
'"+pubID+"'"
overseas1 = conn.query(sqlcheck1)
pubType = cmi.fetch_rows(overseas1)
"""

hermes is apparently some wrapper that magically can connect to a
well-known database (via the argumentless db()) call. Who knows what
kind of animal the 'conn' object is that comes out of that db() call.
Apparently it's an object with a query() method that returns something
like a cursor that can be passed into cmi.fetch_rows(). At this point I
wonder why the responsibility of fetching rows is in a module separate
from the responsibility of establishing a database connection.

Legacy code, indeed.

-Carsten





More information about the Python-list mailing list