Connect MySQl with Python错误:找不到函数“inet\u pton”

2024-10-05 14:28:52 发布

您现在位置:Python中文网/ 问答频道 /正文

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()

调试时出现以下错误:

^{pr2}$

我的代码怎么了?请帮忙修好,非常感谢!
连接器从Mysql官方网站下载,
我使用的是python3.3
我在google上找到了这个,这是Mysql的Bug?因为我用的是windowsxp。 http://bugs.mysql.com/bug.php?id=68065


Tags: addhostconnectormysqlemployeepasswordcursordatabase