On 29 dic, 20:31, [EMAIL PROTECTED] wrote: > I can't figure out why this doesn't work. Any ideas appreciated. > > conn = MySQLdb.connect (db = "vocab") > cursor = conn.cursor () > cursor.execute ("SELECT VERSION()") > row = cursor.fetchone () > print "server version:", row[0] > cursor.close () > conn.close () > > gives: > > server version: 5.0.44-log > > but > > import defs > conn = MySQLdb.connect (defs.connect) > [...] > where defs.py is > > connect = 'db = "vocab"' > > gives: > > Traceback (most recent call last): > _mysql_exceptions.OperationalError: (2005, 'Unknown MySQL server host > \'db = "vocab"\' (3)')
Try this: defs.py: dbname = "vocab" import defs conn = MySQLdb.connect(db=defs.dbname) BTW, please read the Style Guide at http://www.python.org/dev/peps/pep-0008 - in particular, I feel space before an opening parens rather annoying. But it's just a matter of style. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list