作者:莫怀嘉805 | 来源:互联网 | 2023-05-16 16:13
IamabeginnerSQLiteuserandhasrunintosometrouble,hopingtofindsomeonewhocouldhelp.我是
I am a beginner SQLite user and has run into some trouble, hoping to find someone who could help.
我是初学SQLite用户,遇到了一些麻烦,希望能找到可以提供帮助的人。
I am trying to read some data out of a database, put it into a variable in python and print it out onto a HTML page.
我试图从数据库中读取一些数据,将其放入python中的变量并将其打印到HTML页面上。
The table inside the database is calle "Status", it contains two columns "stamp" and "messages". "stamp is an INT containing a time stamp, and "messages" contains a TEXT.
数据库中的表是calle“Status”,它包含两列“stamp”和“messages”。 “stamp是包含时间戳的INT,”messages“包含TEXT。
@cherrypy.expose
def comment(self, ID = None):
con = lite.connect('static/database/Status.db')
output = ""
with con:
cur = con.cursor()
cur.execute("SELECT * FROM Status WHERE stamp = ?", (ID,))
temp = cur.fetchone()
output = temp[0]
comments = self.readComments(ID)
page = get_file(staticfolder+"/html/commentPage.html")
page = page.replace("$Status", output)
The error I am getting reads:
我得到的错误是:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/cherrypy/_cprequest.py", line 606, in respond
cherrypy.response.body = self.handler()
File "/usr/lib/pymodules/python2.7/cherrypy/_cpdispatch.py", line 25, in __call__
return self.callable(*self.args, **self.kwargs)
File "proj1base.py", line 184, in comment
page = page.replace("$Status", output)
TypeError: expected a character buffer object
I was wondering if anyone could help me clarify what a character buffer object is, and how do i use one in order for my code to work?
我想知道是否有人可以帮我澄清字符缓冲区对象是什么,以及如何使用一个以使我的代码工作?
1 个解决方案