Skip to content

Instantly share code, notes, and snippets.

@nonZero
Created May 22, 2016 13:14
Show Gist options
  • Save nonZero/878e242d2bf5a171a23adcaee74c6a30 to your computer and use it in GitHub Desktop.
Save nonZero/878e242d2bf5a171a23adcaee74c6a30 to your computer and use it in GitHub Desktop.
from pprint import pprint
import pymongo
client = pymongo.MongoClient()
db = client.get_database('socialagg')
# db = client['socialagg']
pages = db.get_collection('pages')
# pages = db['pages']
pages.create_index('id', unique=True)
pages.update({'id': "123456"},
{'id': '123456', 'name':'Donald Duck'},
upsert=True)
for page in pages.find():
pprint(page)
print("Done.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment