数据库操作小记

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))
相关推荐
m0_7373025826 分钟前
解码OpenClaw:让AI从“对话应答”走向“自主执行”的开源智能体
服务器
草莓啵啵~26 分钟前
pywinauto-打开程序+连接已打开的程序
开发语言·python
lishi_19918 小时前
一键部署MoviePilotV2实现NAS全自动追剧
python·媒体·moviepilot
tedcloud1238 小时前
RTK部署教程:构建稳定的AI Workflow环境
服务器·javascript·人工智能·typescript·ocr
实心儿儿9 小时前
Linux —— 线程控制(1)
linux·运维·服务器
测试开发-学习笔记9 小时前
代码详细解释
python
u0119608239 小时前
ray-k8s部署
python
weixin_397574099 小时前
用自然语言查数据库出图表靠谱吗?一次智能问数实践复盘
数据库
Bruce_kaizy10 小时前
c++ linux环境编程——文件io介绍以及open 、write 、read 三剑客深度详解
linux·服务器·c++·ubuntu·操作系统·文件io
字节跳动开源11 小时前
Viking AI 搜索 CLI 正式发布:会说话,就能做搜索推荐
数据库·人工智能·开源