473,765 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.NoneTyp e))]
self.user =
[user,variables. USER][isinstance(user ,(types.NoneTyp e))]
self.password =
[password,variab les.PASSWORD][isinstance(pass word,(types.Non eType))]
self.database =
[database,variab les.DATABASE][isinstance(data base,(types.Non eType))]

self.bActive = True
self.bConnected = False

def OpenDB(self):

success = False
if self.bActive:
try:
self.conn = adodb.NewADOCon nection('mysql' )
if not self.conn:
Log.log("Can't connecto to DB-Mysql")
success = False
else :
#Create the connection
ret = self.conn.Conne ct(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("Execut ing Query: " + str(query))
cursor = self.conn.Execu te(query)
if cursor:
while not cursor.EOF:
if not simple:
resultado.appen d(cursor.GetRow Assoc())
cursor.MoveNext ()
else :
resultado.appen d(cursor.FetchR ow())
#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.Begin Trans()

#Execute each query in lQueries
for query in lQueries:
self.conn.Execu te(query)
if self.conn._errn o != 0 :
success = False
break;
else:
success = True

#End of transaction
if success:
self.conn.Commi tTrans()
else:
self.conn.Rollb ackTrans()

#Closing DB
self.CloseDB()
return success

def TestConnection( self):
if self.OpenDB():
self.CloseDB()
return True
return False

def CloseDB(self):
if self.conn.IsCon nected() :
self.conn.Close ()
return

Jan 5 '06 #1
0 1640

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

Similar topics

4
2433
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 findings. This set of scripts for the section of the project use an ADODB class for MySQL. I've never used this method before (I wrote a class a while back to handle my MySQL core code which was mainly a wrapper for various mysql_*() functions etc)....
1
2207
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 done. in general terms, does it go like this...
13
7779
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 within that directory OR 2) Within a specific page, set the timeout as per http://www.microsoft.com/windows2000/en/server/iis/default.asp?url=/windows2000/en/server/iis/htm/asp/vbob246s.htm e.g. <% Server.ScriptTimeout = 1 %> and that the value in...
5
13009
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: include('../adodb/adodb.inc.php'); ---->"permission denied" $conn = 'Provider=Microsoft.Jet.OLEDB.4.0;'. 'Data Source=\\\\10.0.0.181\\db\\newres.mdb;'; $rs = NewADOConnection('ado_access'); ----> "unknown command"
0
3248
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 instantiate two adoDB connection like this $db1 = &NewAdoConnection ("mysql"); $db1 = &NewAdoConnection ("oracle"); then you can run queries simultaneously from these connections. but if
3
7292
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 mysql_escape_string(). With ADOdb, is this handled transparently with the execute method or should I take my own steps to sanitize input data? Also, one of the reasons I'm looking at ADOdb is I'd like to start to
0
1869
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) Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. in line objRS.Open mySQL, objConn,adOpenKeyset, adLockPessimistic, adCmdText
2
4594
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 decrypt it because the code specifies a Query. But the INSERT is an ADODB insert: $_POST = 83; .... runQuery($db ->GetInsertSQL($rs, $_POST, true));
0
1550
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 solution i have found is that i have set the recordset to NEW ADODB.RECORDSET two times before actually perfoming the rs.open (once in the main program and once in the dll which contains the loadrecords function). MAIN PROGRAM Dim rs as NEW...
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.