Help req: Problems with MySQLdb
onurb at xiludom.gro
Fri Jun 23 05:19:24 EDT 2006
Simon Forman wrote:
> rodmc wrote:
>>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?
> Use the traceback module (See
> http://docs.python.org/lib/module-traceback.html for info on it.)
> import traceback
> db = MySQLdb.connect(host=DBSERVERIP, user="user",
> passwd="password", db="nuke")
> print "A database connection error has occurred"
How can you assert it is a database connection error ?
> return False
> #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.
> Also, try an empty string (i.e. "") as your hostname, it's shorthand
> for 'localhost'.
> Hope this helps,
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list