472,986 Members | 2,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 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 1572

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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.