2017-08-23 23 views
0

私はソケットを開始します。PyMySQLとソケットスタートは一緒に

両方のモジュールを連携させることはできませんか? 私はSocketとpymysqlが必要です。 私はまた、2つのモジュールをスレッド上で別々に動作させようとしました。残念ながら、これはうまくいかなかった。私はまだ同じエラーが発生します。

エラー:

Exception in thread Thread-2: 
Traceback (most recent call last): 
    File "C:\Users\Erik\Desktop\AT Programmierung\Python\Kommunikation Server-Client\pymysql\connections.py", line 916, in connect 
    **kwargs) 
    File "C:\Users\Erik\AppData\Local\Programs\Python\Python36\lib\socket.py", line 704, in create_connection 
    for res in getaddrinfo(host, port, 0, SOCK_STREAM): 
    File "C:\Users\Erik\AppData\Local\Programs\Python\Python36\lib\socket.py", line 743, in getaddrinfo 
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags): 
socket.gaierror: [Errno 11001] getaddrinfo failed 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "C:\Users\Erik\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner 
    self.run() 
    File "C:\Users\Erik\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864, in run 
    self._target(*self._args, **self._kwargs) 
    File "C:\Users\Erik\Desktop\AT Programmierung\Python\Kommunikation Server-Client\ServerThread.py", line 23, in mysql 
    cursorclass=pymysql.cursors.DictCursor) 
    File "C:\Users\Erik\Desktop\AT Programmierung\Python\Kommunikation Server-Client\pymysql\__init__.py", line 90, in Connect 
    return Connection(*args, **kwargs) 
    File "C:\Users\Erik\Desktop\AT Programmierung\Python\Kommunikation Server-Client\pymysql\connections.py", line 706, in __init__ 
    self.connect() 
    File "C:\Users\Erik\Desktop\AT Programmierung\Python\Kommunikation Server-Client\pymysql\connections.py", line 963, in connect 
    raise exc 
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'dj-eki.de:3306' ([Errno 11001] getaddrinfo failed)") 

答えて

0

私は元々使用して接続しようとしていたが:

connection = pymysql.connect(host='dj-eki.de:3306', 

しかし、それは間違っていたと働いていませんでした。

は代わりに、私はそうのように、ホストからのポートを分離するために必要な:

connection = pymysql.connect(host='dj-eki.de', 
          port=3306,