Home
Sign Up
Sign In
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member
Sign In
V2EX
›
问与答
Python 遍历 mongodb 时,如何保存游标位置到本地
thedog
·
Apr 13, 2018
· 2164 views
This topic created in 2937 days ago, the information mentioned may be changed or developed.
项目中遇到一个需求,需要将一个千万条记录级别的 mongodb 库提取部分字段转到 postgresql 中。
由于 mongodb 一直在更新,所以每隔一段时间就需要倒一次数据。所以想实现增量更新的功能。
问题是,我要如何保存上一次 python 遍历到的位置?
ps:mongodb 的_id 字段是自动生成的,其他字段无严格的递增或递减的数量关系。
MongoDB
字段
Python
游标
1 replies
1
baichi
Apr 14, 2018
find_filter = {
"_id":{"$gt": ObjectId( last_id )}
}
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Solana
·
6032 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 32ms ·
UTC 02:33
·
PVG 10:33
·
LAX 19:33
·
JFK 22:33
♥ Do have faith in what you're doing.
❯