第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python sqlite比較查詢中存儲為文本的日期

Python sqlite比較查詢中存儲為文本的日期

慕尼黑的夜晚無繁華 2022-03-09 20:20:27
我正在使用 Python 并在 sqlite 中構建了一個表。我沒有意識到 Python 有一個用于 sqlite 的時間戳字段類型,所以我將它存儲為文本。下面是我的代碼和結果.. 表中顯示的唯一日期是 for2019-06-18但查詢返回2019-06-19...不知道為什么import sqlite3# Connecting to the database filesqlite_file = 'insta.sqlite'conn = sqlite3.connect(sqlite_file)c = conn.cursor()# Get all rowsc.execute("SELECT * FROM daily_counts")count_row = c.fetchall()for row in count_row:    print(row)# Get Daily Countc.execute('SELECT count FROM daily_counts where current_date = ? and client_id = ? and metric = ?',    ('2019-06-18', 0, 'C'))count_row = c.fetchall()print(count_row)# Get Daily Countc.execute('SELECT count FROM daily_counts where current_date = ? and client_id = ? and metric = ?',    ('2019-06-19', 0, 'C'))count_row = c.fetchall()print(count_row)# Get Daily Countc.execute('SELECT count FROM daily_counts where current_date = ? and client_id = ? and metric = ?',    ('2019-06-20', 0, 'C'))count_row = c.fetchall()print(count_row)結果:(請注意,當條件為 19 時,它返回 18 的結果,而 18 則不返回任何結果..)(0, u'2019-06-18', u'A', 2)(0, u'2019-06-18', u'B', 6)(1, u'2019-06-18', u'C', 180)(1, u'2019-06-18', u'D', 258)(1, u'2019-06-18', u'E', 111)(0, u'2019-06-18', u'C', 180)(1, u'2019-06-18', u'F', 3)[][(180,)][]我假設我應該使用時間戳字段類型而不是文本?但我仍然希望這能奏效
查看完整描述

1 回答

?
GCT1015

TA貢獻1827條經驗 獲得超4個贊

current_date是一個sqlite 保留字。

將雙引號或反引號添加到"current_date"sql 字符串中的列名(例如 ),您應該會得到預期的結果。


查看完整回答
反對 回復 2022-03-09
  • 1 回答
  • 0 關注
  • 221 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號