我的来源
import pymysql
import socket
conn = pymysql.connect(host='127.0.0.1', unix_socket='/tmp/mysql.sock', user='user', passwd=None, db='extractor')
cur = conn.cursor()
cur.execute("SELECT * FROM res")
for response in cur:
print(response)
cur.close()
conn.close()
错误
Traceback (most recent call last):
File "C:\Users\Jonathan\Desktop\python.py", line 20, in <module>
conn = pymysql.connect(host='127.0.0.1', unix_socket='/tmp/mysql.sock', user='bitnami', passwd=None, db='extractor')
File "C:\Python33\lib\site-packages\pymysql\__init__.py", line 93, in Connect
return Connection(*args, **kwargs)
File "C:\Python33\lib\site-packages\pymysql\connections.py", line 510, in __init__
self._connect()
File "C:\Python33\lib\site-packages\pymysql\connections.py", line 658, in _connect
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
AttributeError: 'module' object has no attribute 'AF_UNIX'
>>>