我尝试使用Python连接到mySql数据库。数据库位于免费的网络托管服务器上网址:webzdarma.cz. 在
我使用mysql.connector.connect,我的所有论点在我看来都是正确的。有关连接到数据库的信息包括:This information is for PHP but I suppose it should work with Python:
Server: mysql.webzdarma.cz
Username: flat
Database: flat
Password: xxxx
这是我的代码:
^{pr2}$
尝试运行此代码时出现错误:Traceback (most recent call last):
File "C:/Users/Python/PycharmProjects/Flat/Flat.py", line 6, in
database='flat')
File "C:\Python27\lib\site-packages\mysql\connector\__init__.py", line 159, in connect
return MySQLConnection(*args, **kwargs)
File "C:\Python27\lib\site-packages\mysql\connector\connection.py", line 129, in __init__
self.connect(**kwargs)
File "C:\Python27\lib\site-packages\mysql\connector\connection.py", line 454, in connect
self._open_connection()
File "C:\Python27\lib\site-packages\mysql\connector\connection.py", line 417, in _open_connection
self._socket.open_connection()
File "C:\Python27\lib\site-packages\mysql\connector\network.py", line 470, in open_connection
errno=2003, values=(self.get_address(), _strioerror(err)))
File "C:\Python27\lib\site-packages\mysql\connector\errors.py", line 181, in __init__
self.msg = self.msg % values
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf8 in position 15: ordinal not in range(128)
引发此错误是因为程序收到了有关连接失败的捷克语消息。
有人知道我做错什么了吗?在