Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To support IPv6 #19

Closed
Rhilip opened this issue Oct 27, 2017 · 1 comment
Closed

To support IPv6 #19

Rhilip opened this issue Oct 27, 2017 · 1 comment

Comments

@Rhilip
Copy link

Rhilip commented Oct 27, 2017

When I try to connect my mysql via an ipv6 address, It fails.
However the origin PyMySQL can do it after PyMySQL@b15c673 with
issues PyMySQL#118
Can you also fix it, and update the pypi?

And This is my temporary solution.

diff -Naur cymysql/connections.py cymysql-ipv6/connections.py
--- cymysql/connections.py    2017-06-10 03:51:56.000000000 -0400
+++ cymysql-ipv6/connections.py    2017-10-27 05:12:51.125249151 -0400
@@ -398,13 +398,14 @@
                 self.host_info = "Localhost via UNIX socket"
                 if DEBUG: print('connected using unix_socket')
             else:
-                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-                t = sock.gettimeout()
-                sock.settimeout(self.connect_timeout)
-                sock.connect((self.host, self.port))
+                sock = socket.create_connection((self.host, self.port), self.connect_timeout)
                 self.host_info = "socket %s:%d" % (self.host, self.port)
                 if DEBUG: print('connected using socket')
-            sock.settimeout(t)
         except socket.error as e:
             sock.close()
             raise OperationalError(2003, "Can't connect to MySQL server on %r (%s)" % (self.host, e.args[0]))
nakagami added a commit that referenced this issue Oct 27, 2017
@nakagami
Copy link
Owner

nakagami commented Oct 28, 2017

thanks, I have modified and uploaded it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants