나는 윈도우 10에서 파이썬 3.5.0와 PyMySQL 0.79를 사용하지만 'test.py'라는 간단한 프로그램을 실행할 때 연결 오류를 얻으려고 ...PyMySQL 코드에 연결 오류 Windows 10 Python 3.5.0?
import pymysql
db = pymysql.connect(host = 'sqlserver.example.com', passwd 'SECRET12345', user = 'dbuser', db='myDatabase')
cursor = db.cursor()
sql = "INSERT INTO people (name, email, age) VALUES (%s, %s, %s)"
cursor.execute(sql, ("Jay", "[email protected]", '77'))
cursor.close()
db.commit() #Makes sure the DB saves your changes!
db.close()
그러나 위의 코드 제공 나 오류 메시지 :
을 : 나에게주는'PIP 목록'
C:\Users\Avtar\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\pymysql>test.py
Traceback (most recent call last):
File "C:\Users\Avtar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pymysql\connections.py", line 890, in connect
(self.host, self.port), self.connect_timeout)
File "C:\Users\Avtar\AppData\Local\Programs\Python\Python35-32\lib\socket.py", line 689, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Users\Avtar\AppData\Local\Programs\Python\Python35-32\lib\socket.py", line 728, 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\Avtar\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\pymysql\test.py", line 2, in <module>
db = pymysql.connect(host = 'sqlserver.example.com', passwd = 'SECRET12345', user = 'dbuser', db='myDatabase')
File "C:\Users\Avtar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pymysql\__init__.py", line 90, in Connect
return Connection(*args, **kwargs)
File "C:\Users\Avtar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pymysql\connections.py", line 688, in __init__
self.connect()
File "C:\Users\Avtar\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pymysql\connections.py", line 937, in connect
raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'sqlserver.example.com' ([Errno 11001] getaddrinfo failed)")
내가 명령 'pymysql를 설치 PIP'내가 입력하여 설치를 확인할 수를 사용하여 pyMySQL 설치
Name: PyMySQL
Version: 0.7.9
Summary: Pure Python MySQL Driver
Home-page: https://github.com/PyMySQL/PyMySQL/
Author: INADA Naoki
Author-email: [email protected]
License: MIT
Location: c:\users\avtar\appdata\local\programs\python\python35-32\lib\site-packages
Requires:
내가 잘못하고있는 무슨이에서 말할 수 없다, 그래서 사람이를 정렬 나를 도울 수 있다면 것 정말 감사 :
pip (9.0.1)
PyMySQL (0.7.9)
setuptools (18.2)
yolk (0.4.3)
나에게주는 'pymysql을 보여 PIP'. 미리 감사드립니다.
지연에 대한 사과 - 답장을 보내 주셔서 감사합니다. 솔직히 말해서 "db = pymysql.connect"명령에 무엇이 있어야할지 모르겠습니다. 누락 된 '='을 추가하라는 제안에 따라했지만 여전히 동일한 오류가 발생합니다. 'Microsoft SQL Server'vs 'MySQL'의 관점에서 내가 무엇을 사용해야하는지 확신 할 수 없습니다. 어떻게 결정됩니까? 또한 나열된 명령을 실행하여 포트 번호를 찾는 방법은 무엇입니까? (이 분야에 대한 나의 지식 부족을 용서하십시오). – Avtar