Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Testing MySQLdb connection object

Reply
Thread Tools

Testing MySQLdb connection object

 
 
Bernard Lebel
Guest
Posts: n/a
 
      01-09-2006
Hello,

First, this is my first post on this list!
A little about myself: I'm the lead technical director in a 3D
animation studio, in Montreal. A lot of the Python code I write is to
be used in an application that embeds Python, that is, Softimage|XSI.
Right now I'm re-writing the render farm software that runs on render
nodes, in this project is what made me learn Python in the first
place. My first question is related to that.


Using the MySQLdb module, I create a connection object with a
database. It might happen that the connection is not used for a long
period of time and becomes obsolete, or the connection may simply
close for various reasons.

I'd like to write a safety procedure so that before launching a query
or performing any database operation (like commit, fetch and such),
the procedure checks if the connection object is still working. In
case it is not, it would attempt to create a new one.

I know I could send my query and catch exceptions in order to find
out, but I was wondering if there was something a little more
dedicated to this task that I could try. I have looked into the ping()
method, but it seems to always return None, wich I'm not sure how to
interpret.


Any suggestion is welcomed.


Thanks
Bernard
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need advices for mysqldb connection best practice Romaric DEFAUX Python 0 01-20-2011 09:04 AM
MySQLdb problems with named pipe connection on Windows 7? John Nagle Python 4 06-12-2010 04:44 AM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
Failing connection with MySQLdb on Mac OS X Stephen Roderick Python 0 05-29-2004 10:57 PM
NoneType object returned by .fetchone() in MySQLdb Arnaud-F. FAUSSE Python 2 11-27-2003 06:00 AM



Advertisments