#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    49
    Rep Power
    0

    Error - Python - MySQL


    #!C:\Python24\Python.exe
    # import MySQL module
    import MySQLdb
    # connect
    db = MySQLdb.connect(host="localhost", user="pan",passwd="bbbc",db="test")
    # create a cursor
    cursor = db.cursor()
    # execute SQL statement
    cursor.execute("SELECT * FROM example1")
    # get the resultset as a tuple
    result = cursor.fetchall()
    # iterate through resultset
    for record in result:
    print record[0] , "-->", record[1]


    Here is My CODE

    I get an Error


    Traceback (most recent call last):
    File "C:\Documents and Settings\Arpan Shah\Desktop\Ex.py", line 5, in -toplevel-
    db = MySQLdb.connect(host="localhost", user="pan",passwd="bbbc",db="test")
    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)")

    Please find a solution to this, so that i can get started with DB.

    thanz
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    "Can't connect to MySQL server on 'localhost' (10061)"
    10061 is a general socket failed to connect error. I suspect that: either your MySQL install isn't listening for TCP/IP connections/isn't configured correctly for them/isn't present at all, or you have something blocking the connection, e.g. a firewall.
  4. #3
  5. (retired)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2003
    Location
    The Laboratory
    Posts
    10,101
    Rep Power
    0

IMN logo majestic logo threadwatch logo seochat tools logo