Created
June 22, 2015 13:30
-
-
Save amn41/3c7b25242381fb55b9a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
""" | |
quick and dirty | |
""" | |
client=MongoClient() | |
db=client['treevdb'] | |
gdrivecoll=db['googledriveinformation'] | |
cursor=gdrivecoll.find() | |
for gdinfo in cursor: | |
tppcursor=db.thirdpartyprofiles.find({"_id":gdinfo['profile']}) | |
profiles=[p for p in tppcursor] | |
if (len(profiles) <1): | |
print("warning: no matching profile for gdrive info with id %s"%gdinfo['profile']) | |
continue | |
elif(len(profiles)>1): | |
print("error: multiple matching profiles for gdrive info with id %s"%gdinfo['profile']) | |
exit(1) | |
profile=profiles[0] | |
gdstreampos={} | |
gdstreampos['thirdpartyinfo']={} | |
gdstreampos['thirdpartyinfo']['treevUserId']=profile['treevUserId'] | |
gdstreampos['thirdpartyinfo']['providerId']=profile['providerId'] | |
gdstreampos['thirdpartyinfo']['providerId']=profile['userId'] | |
gdstreampos['content']={} | |
gdstreampos['content']['largestChangeId']=gdinfo['largestChangeId'] | |
gdstreampos['content']['lastUpdated']=gdinfo['lastUpdated'] | |
print gdstreampos | |
db.googledrivestreamposition.insert(gdstreampos) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment