数据库操作小记
PG之最近的年月日小时查询
SELECT * from pool where published_at >= CURRENT_DATE - INTERVAL '6 months' order by published_at desc
#years、months、days、hours、minutes
ORM and、or、以及其他查询的嵌套
or_clause = []
for p in content:
and_clause = [P.chain == p["chain"]]
if p.get("min") and p.get("max"):
and_clause.append(P.liquidity.between(p["min"], p["max"]))
elif p.get("min"):
and_clause.append(P.liquidity >= p["min"])
elif p.get("max"):
and_clause.append(P.liquidity <= p["max"])
or_clause.append(and_(*and_clause))
pool_info = pool_info.filter(or_(*or_clause))
原文地址:https://blog.csdn.net/qq_42691309/article/details/137719303
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!