I
int32bit
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)
cursor = conn.cursor ()
cursor.execute ("SELECT VERSION()")
row = cursor.fetchone ()
print "server version:", row[0]
cursor.close ()
conn.close ()
where defs.py is
connect = 'db = "vocab"'
gives:
Traceback (most recent call last):
File "./add_words", line 17, in ?
conn = MySQLdb.connect (defs.connect)
File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line
74, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py",
line 170, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2005, 'Unknown MySQL server host
\'db = "vocab"\' (3)')
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)
cursor = conn.cursor ()
cursor.execute ("SELECT VERSION()")
row = cursor.fetchone ()
print "server version:", row[0]
cursor.close ()
conn.close ()
where defs.py is
connect = 'db = "vocab"'
gives:
Traceback (most recent call last):
File "./add_words", line 17, in ?
conn = MySQLdb.connect (defs.connect)
File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line
74, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py",
line 170, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2005, 'Unknown MySQL server host
\'db = "vocab"\' (3)')