python中mySQL的最后一个值(查询)
正在尝试从Raspberry Pi上的MySQL获取最后一个值。不知道为什么我的简单代码不能工作,在row=cursor.fetchone的executefirst处给出了错误 这是我的密码:python中mySQL的最后一个值(查询),python,mysql,sql,raspberry-pi,Python,Mysql,Sql,Raspberry Pi,正在尝试从Raspberry Pi上的MySQL获取最后一个值。不知道为什么我的简单代码不能工作,在row=cursor.fetchone的executefirst处给出了错误 这是我的密码: # External module imports import time import os import datetime import MySQLdb # Connect to mysql db=MySQLdb.connect("localhost","zikmir","gforce","temp
# External module imports
import time
import os
import datetime
import MySQLdb
# Connect to mysql
db=MySQLdb.connect("localhost","zikmir","gforce","temp_database")
# Prepair a cursor
cursor=db.cursor()
# Select three columns, id, time and temp from table time_temp
cursor.execute = ("SELECT id, time, temp FROM time_temp")
# ID is autoincremented value, time is in TIME and temp is float
row = cursor.fetchone()
# Trying to store the last result in variable row
# Close cursor and database
cursor.close()
db.close()
观察=incrisor.execute=从时间中选择id、时间、温度。它应该读取游标。执行选择 看起来是正确的:但是如果时间表中没有数据,它将失败_temp@NorbertvanNobelen我确实在表中有数据,我正在推送数据,并在我的php网站上成功地获取数据。www.ziks.ca