数据库操作小记

PG之最近的年月日小时查询

sql 复制代码
SELECT * from pool where published_at >= CURRENT_DATE - INTERVAL '6 months' order by published_at desc 
#years、months、days、hours、minutes

ORM and、or、以及其他查询的嵌套

python3 复制代码
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))
相关推荐
deephub17 小时前
dLLM:复用自回归模型权重快速训练扩散语言模型
人工智能·python·语言模型·大语言模型
itwangyang52018 小时前
AIDD-人工智能药物设计-字节跳动 PXDesign:AI 设计蛋白,82% 命中率惊艳业界
人工智能·python
Biehmltym18 小时前
【AI】01开发环境:Conda_python包/环境管理,10分钟上手
开发语言·python·conda
你好helloworld18 小时前
linux离线安装nvidia-docker
linux·运维·服务器
袁气满满~_~18 小时前
Python练习
开发语言·python
我可以将你更新哟18 小时前
【爬虫】爬取斗罗大陆漫画,面向对象封装(存入数据库)
数据库·爬虫·python
忙里偷闲学python18 小时前
mysql
linux·数据库·mysql·oracle
byzh_rc18 小时前
[算法设计与分析-从入门到入土] 递归
数据库·人工智能·算法·机器学习·支持向量机
麦麦大数据18 小时前
F060 基于BERTvue+flask电影评论情感分析系统
后端·python·flask·bert·推荐算法·情感分析·电影评论
yongche_shi18 小时前
第八十九篇:CAP理论、BASE理论在系统设计中的应用
开发语言·python·面试宝典·cap理论·base理论