python - 查找 sqlalchemy 中表之间的缺失值

标签 python sqlalchemy

I have two tables with a common field I want to find all the the items(user_id's) which present in the first table but not in the second.

Table1(user_id,...)
Table2(userid,...)

Table1和Table2中的user_id是指向另一个表中同一列的外键。

最佳答案

session.query(Table1.user_id).outerjoin(Table2).filter(Table2.user_id == None)

关于python - 查找 sqlalchemy 中表之间的缺失值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17541225/

相关文章:

python - Homebrew ,python安装

python - 为什么这个函数从数据库返回 None ?

Mysql 跨 2 列的唯一约束

python - 使用 Scrapy 而非 Scraped Items 从表中抓取数据

python - Scipy 的 RectBivariateSpline 返回错误值?

python pip 损坏,无法修复或卸载

python - 三列 Pandas 中具有多个条件的 cumsum

python - 通过 SQLAlchemy 执行 Teradata MERGE 时不会产生任何结果

python - 如何在Python中使用SQLalchemy过滤SQL表中的日期时间列?

python - 如何将 python `dict` 转换为 `sqlalchemy.engine.row`