Hi to all, I'm using adodb for accessing mysql and postgres. My problem relies on the mysql access.
Sometimes, when I try to execute a query (using ExecTrans method below), I get this error: 'NoneType' object has no attribute 'cursor' Maybe this error ocurrs not in my code, but in the mysql module. Does anyone had had this problem? Thanks. The following is my DB connection class. class DB: def __init__(self, host=None, user=None, password=None, database=None): self.host = [host,variables.IP_DB][isinstance(host,(types.NoneType))] self.user = [user,variables.USER][isinstance(user,(types.NoneType))] self.password = [password,variables.PASSWORD][isinstance(password,(types.NoneType))] self.database = [database,variables.DATABASE][isinstance(database,(types.NoneType))] self.bActive = True self.bConnected = False def OpenDB(self): success = False if self.bActive: try: self.conn = adodb.NewADOConnection('mysql') if not self.conn: Log.log("Can't connecto to DB-Mysql") success = False else : #Create the connection ret = self.conn.Connect(self.host, self.user, self.password, self.database) if ret: Log.log("DB-Mysql connection stablished") success = True except: success = False pass else: print "DB connection disabled" self.bConnected = success return success def Exec(self,query,simple=False): resultado = list() #Open a DB connection if self.OpenDB(): Log.log("Executing Query: " + str(query)) cursor = self.conn.Execute(query) if cursor: while not cursor.EOF: if not simple: resultado.append(cursor.GetRowAssoc()) cursor.MoveNext() else : resultado.append(cursor.FetchRow()) #Close Cursor cursor.Close() else: resultado = None self.CloseDB() else: resultado = None return resultado def ExecTrans(self, lQueries): success = False if self.OpenDB(): print "Executing Querys: " + str(lQueries) #Begin Transaction self.conn.BeginTrans() #Execute each query in lQueries for query in lQueries: self.conn.Execute(query) if self.conn._errno != 0 : success = False break; else: success = True #End of transaction if success: self.conn.CommitTrans() else: self.conn.RollbackTrans() #Closing DB self.CloseDB() return success def TestConnection(self): if self.OpenDB(): self.CloseDB() return True return False def CloseDB(self): if self.conn.IsConnected() : self.conn.Close() return -- http://mail.python.org/mailman/listinfo/python-list