数据库操作小记

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))
相关推荐
han_hanker7 分钟前
sql语法 DECODE, CASE ... WHEN
数据库·sql·oracle
aramae8 分钟前
C++ IO流完全指南:从C标准库到C++流式编程
服务器·c语言·开发语言·c++·后端
ZHOU_WUYI11 分钟前
4. light wam 模型loss计算过程
开发语言·人工智能·python
井川廊咏15 分钟前
vi 删除指定范围的行,不用再反复按 dd
数据库·mysql
nwsuaf_huasir20 分钟前
【无标题】
python
z落落1 小时前
StudentInfo表 分页、增删改 存储过程+C# WinForm 存储过程实现分页和增删改查
数据库·sql·mysql
影寂ldy1 小时前
WinForm 数据库【新增+编辑】完整功能(参数化查询+配置文件+防报错全套)
数据库
迷枫7122 小时前
达梦数据库 Hint 使用与 Hint 注入实战
数据库
M哥支付2 小时前
什么是收付一体模式?
服务器·网络·其他·微信·金融
Python私教2 小时前
Codex 写出的代码能跑却算错钱:我用 3 个测试拆穿一次 AI 编程幻觉
python·单元测试·ai编程