troubleshooting Question

Disconnected Recordset Problem

Avatar of jmhofhine
jmhofhine asked on
Python
2 Comments1 Solution278 ViewsLast Modified:
I'm having a problem with a function I wrote.  Basically what it needs to do is run a select statement on one mysql database, if it returns empty, run the same select statement on a different mysql database.  The function then returns the recordset. The recordcount of the recordset is always -1.   If I take out     oDB.disconnect()   &  del oDB, it works.  Do I have to close the connection and delete the db object?  
def getRecordSet(conStr, sql, sysInfo):
    localDb = ""
    oDB = clsAdo()
    
    if (conStr.find("config") <> -1):
        localDb = sysInfo.configDbLocal
    elif (conStr.find("spd") <> -1):
        localDb = sysInfo.spdDbLocal
    
    if (localDb <> ""):
        if ( oDB.connect(localDb) == False ):
            displayErrorMsg("getRecordSet", "smt_utility.py", "Could not connect to the Database.", 1)
 
 
        oRS = oDB.getResultSet(sql)[0]
 
 
        if (oRS.EOF):
            oDB.Disconnect()
            if ( oDB.Connect(conStr) == False ):
                displayErrorMsg("getRecordSet", "smt_utility.py", "Could not connect to the Database.", 1)
 
    
            oRS = oDB.getResultSet(sql)[0]
 
            
    else:
        if ( oDB.connect(conStr) == False ):
            displayErrorMsg("getRecordSet", "smt_utility.py", "Could not connect to the Database.", 1)
 
  
    oRS = oDB.getResultSet( sql )
    
    oDB.disconnect()        
    del oDB
    return oRS
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros