Tuesday, 15 February 2011

mysql python - Pycharm MySQLdb 'module' object has no attribute 'Number' -



mysql python - Pycharm MySQLdb 'module' object has no attribute 'Number' -

the next programme executes using python script , gives me expected output :

database version : 5.6.19-0ubuntu0.14.04.1

however, exact same programme doesn't seem work on pycharm.

it outputs:

/usr/bin/python2.7 /home/shog/pycharmprojects/pythonadvancedtutorial/databases.py traceback (most recent phone call last): file "/home/shog/pycharmprojects/pythonadvancedtutorial/databases.py", line 12, in <module> db = mysqldb.connect('localhost', 'root', '*****', 'testdb') file "/usr/local/lib/python2.7/dist-packages/mysql_python-1.2.4b4-py2.7-linux-x86_64.egg/mysqldb/__init__.py", line 81, in connect homecoming connection(*args, **kwargs) file "/usr/local/lib/python2.7/dist-packages/mysql_python-1.2.4b4-py2.7-linux-x86_64.egg/mysqldb/connections.py", line 147, in __init__ mysqldb.converters import conversions file "/usr/local/lib/python2.7/dist-packages/mysql_python-1.2.4b4-py2.7-linux-x86_64.egg/mysqldb/converters.py", line 174, in <module> decimal import decimal file "/usr/lib/python2.7/decimal.py", line 3743, in <module> _numbers.number.register(decimal) attributeerror: 'module' object has no attribute 'number'

here program:

#!/usr/bin/python import mysqldb db = mysqldb.connect('localhost', 'root', '2soid', 'testdb') cursor = db.cursor() cursor.execute("select version()") info = cursor.fetchone() print "database version : %s " % info db.close()

remove #!/usr/bin/python or alter #!/usr/bin/env python, you're calling wrong python library

pycharm mysql-python

No comments:

Post a Comment