Skip to content

Instantly share code, notes, and snippets.

@rtpg
Created April 17, 2016 13:52
Show Gist options
  • Save rtpg/e0ede97e2475e4a591a1401b351e8bde to your computer and use it in GitHub Desktop.
Save rtpg/e0ede97e2475e4a591a1401b351e8bde to your computer and use it in GitHub Desktop.
pymongo Cheatsheet
db = MongoClient('localhost', 27017).some_db # some_db is the DB name
db.table_name.insert_one({ # table name
'key1': value1,
'key2': value2
})
db.table_name.update_many({'key1':'some_value'}, # update all elts with key1 == 'some_value', setting key2 to 'processed'
{'$set': {'key2': 'processed'})
db.table_name.find({'key1': 'some_value'}) # get an iterator with the values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment