Bug #68065 Python mysql.connector don't connect to database in WinXP and Win2003
Submitted: 10 Jan 2013 6:17 Modified: 26 Feb 2013 12:58
Reporter: ce jiang Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S1 (Critical)
Version:1.0.8 OS:Microsoft Windows (XP)
Assigned to: Geert Vanderkelen CPU Architecture:Any

[10 Jan 2013 6:17] ce jiang
Description:
Use mysql.connector.connect() in Winxp or Win2003 will lead to failure. Because it call ctypes.WinDLL('ws2_32.dll').inet_pton(). The function "inet_pton" in Windows 7 "ws2_32.dll", but in Windows XP or 2003.

How to repeat:
Use mysql.connector.connect() in Winxp or Win2003 will lead to failure. Because it call ctypes.WinDLL('ws2_32.dll').inet_pton(). The function "inet_pton" in Windows 7 "ws2_32.dll", but in Windows XP or 2003.
[14 Jan 2013 20:37] Geert Vanderkelen
Hi,

Could you please tell us which Python version was used?
[16 Jan 2013 5:00] Andrei Mikhailov
Python is of 2.7.3 version.
But I think that it is not so critical information.
This bug does not depend upon Python version. It depends upon Windows XP.
In last version of Windows XP ws2_32.dll does not contain inet_pton() function.
But your Python mysql.connector tries to call it.
The temporary solution for me was Python mysql.connector version 1.0.7
[23 Jan 2013 12:25] Geert Vanderkelen
The problem is not dependent on Python version, indeed.
Digging more into it, the inet_pton does not exists in WinXP/Win2003 and we need to find an alternative, which would be WSAStringToAddressA, but maybe just completely different. Later MS Windows versions introduce the better known inet_pton.
[19 Feb 2013 7:22] PBL Narasimha Rao
We too have the same problem. 
we are using Python 2.6.4 x32 on Win XP x64 with MySQL 5.5.23

when can we expect 1.0.9 with this bug fixed. Or is there any alternative for time being.

Thx
[26 Feb 2013 12:58] Geert Vanderkelen
Please check MySQL Connector/Python 1.0.9.
[26 Feb 2013 13:02] Geert Vanderkelen
Changelog for 1.0.9:

Fixed IPv6 for older Microsoft Windows versions. Also improved the associated code for all operating systems: we now use socket.getaddrinfo() instead of inet_pton() to check whether we are connecting using IPv4 or IPv6.

A new connection option force_ipv6 has been introduced. When set to True, IPv6 will be used when an address resolves to both IPv4 and IPv6. Otherwise, IPv4 is favored.