Simon Forman wrote: > rodmc wrote: > >>Hi, >> >>Thanks for your email. Well I am kind of new to exceptions in Python, >>but here is the code used below, as you can see it is somewhat basic. >>Is there a way to display more information about the exception? >> >>Best, >> >>rod >> > > > Use the traceback module (See > http://docs.python.org/lib/module-traceback.html for info on it.) > > import traceback > > try: > db = MySQLdb.connect(host=DBSERVERIP, user="user", > passwd="password", db="nuke") > except: > print "A database connection error has occurred"
How can you assert it is a database connection error ? > traceback.print_exc() > return False > else: > pass > > #The rest of the program You get the same result - with a more accurate error message - by not handling the exception at all. > > It's generally very difficult to figure out what's going wrong without > the traceback in front of you. indeed. > Also, try an empty string (i.e. "") as your hostname, it's shorthand > for 'localhost'. > > > Hope this helps, > ~Simon > -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list