我已经完成了搜索并且对同一错误的现有评论没有帮助
该行:
con = MySQLdb.connect(host = '127.0.0.1', user = 'root', passwd = '', db='vendors', port='3306')
抛出:
Traceback (most recent call last):
File "mysqlpython.py", line 12, in <module>
con = MySQLdb.connect(host = '127.0.0.1', user = 'root', passwd = '', db='vendors', port='3306')
File "/apollo/env/AWSSDKMetrics/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/apollo/env/AWSSDKMetrics/lib/python2.7/site-packages/MySQLdb/connections.py", line 188, in __init__
super(Connection, self).__init__(*args, **kwargs2)
TypeError: an integer is required
对整数的引用是什么?它指的是哪个领域?请记住,我不是python程序员或开发人员。
答案 0 :(得分:4)
您需要将端口指定为数字,而不是字符串:
con = MySQLdb.connect(
host='127.0.0.1',
user='root', passwd='',
db='vendors',
port=3306)
我使用多行来使上面的例子更具可读性;该错误指出port
的值必须是整数。