473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

A weird problem (adodb + mysql)

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

Jan 5 '06 #1
0 1609

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ian.H | last post by:
Hi all, I've taken on a massive project for a client recently and now I've hit some bug fixes that are required (3rd party code). and was just wondering about peoples opinions / personal...
1
by: skeeterbug | last post by:
hi all, i'm new to using php, adodb and pgsql. i have a need to enter data into a database. however, i can't find a web example or tutorial that explains the nuts and bolts of how this is...
13
by: Patrick | last post by:
I understand that with IIS5.1 on Windows XP Professional SP1, I can 1) Either set under IIS Manager-> Any specific Virtual Directory-> Configuration->Options->ASP Script timeout for all pages...
5
by: Bill | last post by:
Hi, I discovered adodb and is use it now in order to connect from PHP to ms Access under Windows. No problem. Is this also applicable to PHP under linux, because i get a lot of errors like:...
0
by: CountDraculla | last post by:
Fixing Multiple Database bug in adoDB popular data access layer for php, adoDB can support multiple databases from different provider at time, but not from same provider. what I mean is if you...
3
by: Tom | last post by:
I'm interested in adopting ADOdb (actually ADOdb Lite) and have a simple question that I haven't been able to quite pinpoint an answer to. I'm used to using the native mysql functions with...
0
by: sonasiva | last post by:
hai Iam creating website using ASP i wnts my clients to register first to vist site using username and password,,this i need to do iam getting error like this ADODB.Recordset (0x800A0BB9)...
2
by: Paul | last post by:
I encrypted a database field using MySQL AES_ENCRYPT() from a mysql command prompt. But I need to encrypt and decrypt at will in the php code as records are added and viewed. I can easily...
0
by: PCroser | last post by:
I have encountered a problem when querying a table. The query passed data into a recordset which should have resulted in many records but has returned EOF. After debugging the code the only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.