Created
April 17, 2016 13:52
-
-
Save rtpg/e0ede97e2475e4a591a1401b351e8bde to your computer and use it in GitHub Desktop.
pymongo Cheatsheet
This file contains 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
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