Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python中mySQL的最后一个值(查询)_Python_Mysql_Sql_Raspberry Pi - Fatal编程技术网

python中mySQL的最后一个值(查询)

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

正在尝试从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_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