2

Example:

import MySQLdb
conn = MySQLdb.connect(passwd="passwd", db="mydb")
cursor = conn.cursor()
cursor.execute("""SELECT * FROM table""")
records = cursor.fatchone()
print records

provides the next error:

Traceback (most recent call last): File
"/Applications/eclipse/plugins/org.python.pydev.debug_2.2.2.2011100512/pysrc/pydevd.py",
line 1267, in
debugger.run(setup['file'], None, None) File "/Applications/eclipse/plugins/org.python.pydev.debug_2.2.2.2011100512/pysrc/pydevd.py", line 1020, in run
pydev_imports.execfile(file, globals, locals) #execute the script File "/Users/user/Documents.Develop/workspace/myProject/src/Main.py",
line 56, in
import MySQLdb File "build/bdist.macosx-10.7-intel/egg/MySQLdb/init.py", line 19, in
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7,
in File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line
6, in bootstrap ImportError:
dlopen(/Users/user/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so,
2): Library not loaded: libmysqlclient.18.dylib Referenced from:
/Users/user/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so
Reason: image not found

Where's the error?

Johan
  • 74,508
  • 24
  • 191
  • 319
Ron D.
  • 3,774
  • 6
  • 31
  • 39

1 Answers1

2

The error seems to be here:

Library not loaded: libmysqlclient.18.dylib Referenced from:

Make sure you install the mysqldb library.
See: How to install MySQLdb package? (ImportError: No module named setuptools)
and/or: http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/

You also have a syntax error in your code:

records = cursor.fatchone() 
--> should be
records = cursor.fetchone() 
Community
  • 1
  • 1
Johan
  • 74,508
  • 24
  • 191
  • 319