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

    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    0

    Mysqldb connection problem


    i already installed mysql-python, but having problem like this

    mysql.py
    Code:
    #!/usr/bin/python
    import MySQLdb
    
    db = MySQLdb.connect(host="localhost", user="root", passwd="1234567", db="test")
    
    cur = db.cursor()
    
    #execute an sql query
    cur.execute("SELECT firstname,lastname FROM test.email")
    
    ##Iterate 
    for row in cur.fetchall() :
          #data from rows
            firstname = str(row[0])
            lastname = str(row[1])
    
          #print 
            print "This Person's name is " + firstname + " " + lastname
    
    # close the cursor
    cur.close()
    
    # close the connection
    db.close ()
    debug

    Code:
    Zainuddin-MacBook-Pro:python zainuddin$ python mysql.py 
    Traceback (most recent call last):
      File "mysql2.py", line 4, in <module>
        db = MySQLdb.connect(host="localhost", user="root", passwd="1234567", db="test")
      File "/Library/Python/2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
        return Connection(*args, **kwargs)
      File "/Library/Python/2.7/site-packages/MySQLdb/connections.py", line 147, in __init__
        from MySQLdb.converters import conversions
      File "/Library/Python/2.7/site-packages/MySQLdb/converters.py", line 54, in <module>
        ArrayType = array.array
    AttributeError: 'module' object has no attribute 'array'
    please help me, i need your advise. tq
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Posts
    153
    Rep Power
    5
    MySQLdb appears to be incorrectly installed. How did you install it?

IMN logo majestic logo threadwatch logo seochat tools logo