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
从http://pypi.python.org/pypi/mysql-connector-python下载连接器后问题解决了,mysql官网的连接器不能使用
哦,这很中肯,我也遇到了同样的问题。谢谢,真的很管用。 看来隐私版(1.0.7)还可以,v1.0.8就不好了。在
ps.真正的下载链接是: http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-1.0.7.zip
安装教程在dir'doc'中。在
相关问题 更多 >
编程相关推荐