This is my first post, so bear with me... (how do I post clean code blocks, for example?)
I'm fairly new to python, and extremely new to MySQL. I am starting with the book "MySQL Cookbook". I have a server running. I have a basic database and am able to interact with it just fine. When I attempted the most basic script however, things fall apart for me.
Using...
Python 2.5.1
ՄեՍԽԼ 5.1.22 rc-win32 (on Windows XP)
Simple example (python shell)...
>>> Import MySQLdb
>>> db = MySQLdb.connect(db='cookbook', host='localhost', user='USERNAME', passwd='PASSWORD')
Traceback (most recent call last):
File "<console>", line 0, in <module>
File "C:\Python25\Lib\site-packages\MySQLdb__init.py", line 74, in Connect
return Connection(args, *kwargs)
File "C:\Python25\Lib\site-packages\MySQLdb\connections.py", line 170, in init
super(Connection, self).init__(args, *kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")
db = MySQLdb.connect()
More complex example (trying to wrap in to an object)...
if name == "main":
oSQL = TestSQL()
oSQL.Connect( "cookbook", "localhost", "USERNAME", "PASSWORD" )
Result:
ERROR:root:2003, Can't connect to MySQL server on 'localhost' (10061)
Traceback (most recent call last):
File "D:\Work\IFW\Dev\Global\lib\cookbookConn.py", line 25, in Connect
passwd = sPass )
File "C:\Python25\Lib\site-packages\MySQLdb__init.py", line 74, in Connect
return Connection(args, *kwargs)
File "C:\Python25\Lib\site-packages\MySQLdb\connections.py", line 170, in init
super(Connection, self).init__(args, *kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
This is my first post, so bear with me... (how do I post clean code blocks, for example?)
I'm fairly new to python, and extremely new to MySQL. I am starting with the book "MySQL Cookbook". I have a server running. I have a basic database and am able to interact with it just fine. When I attempted the most basic script however, things fall apart for me.
Using...
Python 2.5.1
ՄեՍԽԼ 5.1.22 rc-win32 (on Windows XP)
Simple example (python shell)...
>>> Import MySQLdb
>>> db = MySQLdb.connect(db='cookbook', host='localhost', user='USERNAME', passwd='PASSWORD')
Traceback (most recent call last):
File "<console>", line 0, in <module>
File "C:\Python25\Lib\site-packages\MySQLdb__init.py", line 74, in Connect
return Connection(args, *kwargs)
File "C:\Python25\Lib\site-packages\MySQLdb\connections.py", line 170, in init
super(Connection, self).init__(args, *kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")
db = MySQLdb.connect()
More complex example (trying to wrap in to an object)...
Import
import sys, logging
import MySQLdb
logging.basicConfig()
_oLog = logging.getLogger()
CLASS
class TestSQL(object):
if name == "main":
oSQL = TestSQL()
oSQL.Connect( "cookbook", "localhost", "USERNAME", "PASSWORD" )
Result:
ERROR:root:2003, Can't connect to MySQL server on 'localhost' (10061)
Traceback (most recent call last):
File "D:\Work\IFW\Dev\Global\lib\cookbookConn.py", line 25, in Connect
passwd = sPass )
File "C:\Python25\Lib\site-packages\MySQLdb__init.py", line 74, in Connect
return Connection(args, *kwargs)
File "C:\Python25\Lib\site-packages\MySQLdb\connections.py", line 170, in init
super(Connection, self).init__(args, *kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")
Sorry about the formatting. Help would be appreciated there. I would be happy to re-post.
Also,
ՄեՍԽԼ 5.1.22 rc-win32 (on Windows XP)
Should have been:
MySQL 5.1.22 rc-win32 (on Windows XP)