Skip to content

Instantly share code, notes, and snippets.

@amn41
Created June 22, 2015 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amn41/3c7b25242381fb55b9a2 to your computer and use it in GitHub Desktop.
Save amn41/3c7b25242381fb55b9a2 to your computer and use it in GitHub Desktop.
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