当我将具有整数值的内容存储为字符串时,当我检索它时,它突然变成了一个 int。
所以这就是我所看到的:我用这个存储
db = get_db()
hello = escape(str(request.form['name'])).striptags()
what = escape(str(request.form['content'])).striptags()
db.execute('''insert into entry (
title, content, score, approved, pub_date) values (?, ?, 0, 0,?)''',
[hello,what,int(time.time())])
raise Exception('what')
db.commit()
当我从页面提交时,说form['name']='1'and form['content']='2', at the Exception, hello==u'1'and content==u'2'。到目前为止,这一切都很好。然后我存储在 中DB,但是当我去检索时,突然条目是 typeint 1和2。对于任何其他字符串,一切正常,例如"lorem ispum".
在我的sql schema,title和content都是类型string。这是怎么回事?