【问题标题】:Connect MySQl with Python Error : function 'inet_pton' not found使用 Python 错误连接 MySQl:找不到函数“inet_pton”
【发布时间】:2013-02-07 17:14:12
【问题描述】:
import mysql.connector

    cnx = mysql.connector.connect(user=user, password=password,host=host,database=database)
    cursor = cnx.cursor()
    add_employee = ("INSERT INTO tbl_gps "
    "(Locating, MainPower, Acc, PowerOff, Alarm,Speed,Direction,Latitude,Longitude,DateTime,IOState,OilState,MainID) "
    "VALUES (%s, %s, %s, %s, %s,% s, %s, %s, %s, %s, %s, %s, (SELECT MainID From tbl_device WHERE DeviceID = %s))")
    data_employee = {
                  'Locating': 1,
                  'MainPower': 1,
                  'Acc': 1,
                  'PowerOff': 1,
                  'Alarm': 0x80,
                  'Speed': 1,
                  'Direction': 300,
                  'Latitude': 10.00,
                  'Longtitude': -20.00,
                  'DateTime': '2013/2/8 01:00:00',
                  'IOState': 0,
                  'OilState': 0,
                  'MainID': 'NR09533'
                }
    cursor.execute(add_employee, data_employee)
    cnx.close()

当我调试时得到以下错误:

AttributeError: function 'inet_pton' not found

我的代码有什么问题?请帮忙解决,非常感谢!
连接器是从Mysql官网下载的,
我正在使用 Python 3.3
我在谷歌找到了这个,这是一个 Mysql 错误?因为我使用的是 Window XP。 http://bugs.mysql.com/bug.php?id=68065

【问题讨论】:

    标签: python mysql sql database


    【解决方案1】:

    问题解决了我从http://pypi.python.org/pypi/mysql-connector-python下载连接器后,mysql官网的连接器无法使用

    【讨论】:

      【解决方案2】:

      哦,这很重要,我遇到了同样的问题。谢谢,它确实有效。 看来privous版本(1.0.7)还可以,v1.0.8不好。

      ps。真正的下载链接是: http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-1.0.7.zip

      安装教程在目录'doc'中。

      【讨论】:

        猜你喜欢
        • 2018-07-18
        • 2017-10-05
        • 2017-04-19
        • 2012-07-25
        • 1970-01-01
        • 2023-03-23
        • 1970-01-01
        • 1970-01-01
        • 2019-05-10
        相关资源
        最近更新 更多