where do you run database scripts/where are DBs 'located'?

John Salerno johnjsal at NOSPAMgmail.com
Fri May 12 18:04:34 EDT 2006


John Salerno wrote:

> If more information is needed, I will try my local DB when I get home 
> later. 

Ok, here we go:

import MySQLdb

db = MySQLdb.connect(host='localhost',
                      user='johnjsal',
                      passwd='seinfeld',
                      db='bbdatabank')

cursor = db.cursor()
cursor.execute('SELECT * FROM Master')
data = cursor.fetchall()
cursor.close()
db.close()
print data

And the output:

 >>>

Traceback (most recent call last):
   File "C:\Python24\myscripts\db_test.py", line 6, in -toplevel-
     db='bbdatabank')
   File "C:\Python24\lib\site-packages\MySQLdb\__init__.py", line 66, in 
Connect
     return Connection(*args, **kwargs)
   File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line 
134, in __init__
     super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' 
(10061)")
 >>>

The situation is this: I installed MySQL 5.0, created a database called 
bbdatabank using the MySQL prompt. Within the database there is a table 
called Master, which I'm testing on. Obviously something is happening 
with the connect method. Perhaps I'm doing something wrong. Is there a 
way to get more info about what's happening?

Thanks.



More information about the Python-list mailing list