Mysqldb connection problem

A forum for general discussion of the Python programming language.

Mysqldb connection problem

Postby zainuddin » Mon Aug 26, 2013 5:40 am

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

mysql.py
Code: Select all
#!/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: Select all
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
zainuddin
 
Posts: 1
Joined: Mon Aug 26, 2013 5:38 am

Re: Mysqldb connection problem

Postby stranac » Mon Aug 26, 2013 7:07 am

There is one pretty common way errors like this happen.
Do you have a file named 'array.py' or 'array.pyc' in the directory you're executing this from?
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1148
Joined: Thu Feb 07, 2013 3:42 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 2 guests