我是編程新手。我有dictionary
稱爲記錄,它接收各種輸入,如'顏色','類型''數量'等。現在我試着添加一個日期列,然後插入到sqlite表中,通過下面的代碼運行'if循環'。但是我收到了「2017年附近的操作錯誤」,即接近日期。Python sqlite3 - 在「2017」附近的operationalerror
任何人都可以幫忙嗎?在此先感謝
Date = str(datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d'))
record['Date'] = Date
column = [record['Color'], Date]
values = [record['quantity'], record['Date']]
column = ','.join(column)
if record['Type'] == 'T-Shirts' and record['Style'] == 'Soft':
stment = ("INSERT INTO xtrasmall (%s) values(?)" %column)
c.execute(stment, values)
conn.commit()
請參閱http://www.sqlite.org/datatype3.html#datetime。 –