对于一个项目,我需要将事务发送到使用8个值的字符串的R-Pi。例如:
boardone='00000001'
该局方告诉另一个程序打开或关闭继电器。我已经成功地将值的整个“字符串”存储在数据库中,但是使用fetch无法正常工作。这是我的代码:
from datetime import datetime
import MySQLdb as mariadb
connection = mariadb.connect(host="localhost", user="root",
passwd="secretpass", db="secret")
cursor = connection.cursor ()
#We want to recieve the newest transaction from the database
#One other way would be sorting by transaction ID
cursor.execute ("select Column2, Column3 from connectiontest where start
(select MAX(start) from connectiontest)")
received= cursor.fetchone()
cursor.close ()
connection.close ()
Column2和Column3并以以下形式存储在数据库中(以最大时间戳记):
(00000001,00000001)
其中Column2和Column3是无符号,零填充的整数。
收到打印后:
received
Out[410]: (1, 1)
更正的正确语法是什么? fetch命令还是其他问题?