4
我是一个初学SQLite的用户,遇到了一些麻烦,希望找到能帮助的人。在python中,什么是字符缓冲区?
我想从数据库中读取一些数据,将它放入一个python变量中,并将其打印到HTML页面上。
数据库中的表格是calle“Status”,它包含两列“stamp”和“messages”。 “邮票是包含时间戳的INT和‘信息’包含一个文本
@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)
我得到的错误写着:
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
我在想,如果有人可以帮助我澄清什么字符缓冲区对象是,并且我如何使用一个为了我的代码工作?
谢谢你,我意识到它是INT类型,这意味着它被分配col而不是“messages”。一旦我解决了这个问题,它一切正常。非常感谢你。 – Synia 2012-03-31 07:25:02