我是SQLite的初学者,所以如果我要问的问题看起来很愚蠢,请耐心等待。在
我现在有一个名为“Status”的数据库,有两列“stamp”和“messages”“包含时间戳”和“包含时间戳”的消息。在
我想阅读这个数据库的最后10个条目,并将它们显示到一个HTML页面。在
我用来从数据库中读取的代码是:@cherrypy.expose
def readStatus(self):
con = lite.connect('static/database/Status.db')
output = ""
with con:
cur = con.cursor()
cur.execute("SELECT messages FROM Status ORDER BY stamp DESC LIMIT 5")
print "The Status database now contains:"
for row in cur:
print row
output = output + row
return output
我用来将消息打印到HTML页面的代码是
^{pr2}$
但是,我收到以下错误消息:File "proj1base.py", line 133, in homepage
page = page.replace("$STATUS", self.readStatus())
File "proj1base.py", line 305, in readStatus
output = output + row
TypeError: cannot concatenate 'str' and 'tuple' objects
我不完全确定这意味着什么,我假设它是说“output”和“row”之间的类型不匹配。但是,“row”应该读取的是数据库“status”的“messages”列,它是一个字符串,“output”也是一个字符串。所以我不知道发生了什么,我想知道是否有人能帮忙?在