我是Python 2.6的新手。我一直試圖獲取日期datetime值,它的格式爲yyyy-mm-dd hh:m:ss
,在我的Python程序中。在檢查Python中的列類型時,我得到錯誤:'buffer' object has no attribute 'decode'
。我想使用strptime()
函數來拆分日期數據並使用它,但是我找不到如何將緩衝區轉換爲字符串。以下是我的代碼(也可用here)樣本:Python:將緩衝區類型的SQLITE列轉換爲字符串
conn = sqlite3.connect("mrp.db.db", detect_types=sqlite3.PARSE_DECLTYPES)
cursor = conn.cursor()
qryT = """
SELECT dateDefinitionTest FROM t
WHERE IDproject = 4 AND IDstatus = 5
ORDER BY priority, setDate DESC
"""
rec = (4,4)
cursor.execute(qryT,rec)
resultsetTasks = cursor.fetchall()
cursor.close() # closing the resultset
for item in resultsetTasks:
taskDetails = {}
_f = item[10].decode("utf-8")
我得到的例外是:
'buffer' object has no attribute 'decode'
請顯示您的代碼和確切的錯誤。 –
http://pastie.org/5360165 ** dateDefinitionTest **是sqlite3字段的_datetime_ – Volatil3
錯誤我得到:**'緩衝區'對象沒有屬性'解碼'** – Volatil3