數(shù)據(jù)庫(kù)是mysql, 查了文檔沒(méi)有找到exclude,只有個(gè)except_。假如我的表叫做 table_a, 有個(gè)status字段,如果是單一字段,可以使用 != 就做到了exclude,如果是范圍應(yīng)該怎么寫(xiě)?比如有字段date,查詢不在某一時(shí)間范圍的所有記錄,在時(shí)間范圍可以這樣
from datetime import datetime
table_a.query.filter(table_a.date.between(datetime.now()-datetime.timedelta(hours=2), now)))
上面的代碼查詢?cè)诋?dāng)前時(shí)間到2個(gè)小時(shí)前的數(shù)據(jù),如果我想查詢這個(gè)范圍之外的所有數(shù)據(jù)要怎么寫(xiě)?大佬們指導(dǎo)下。
添加回答
舉報(bào)
0/150
提交
取消