create account

Learn Python Series (#19) - PyMongo Part 2 by scipio

View this thread on: hive.blogpeakd.comecency.com
· @scipio · (edited)
$105.08
Learn Python Series (#19) - PyMongo Part 2
# Learn Python Series (#19) - PyMongo Part 2

![python_logo.png](https://cdn.utopian.io/posts/cec1aefe48d5e4ab867572c5230f49626693python_logo.png)

#### What Will I Learn?
- You will learn the remainder of the basic CRUD operations in MongoDB (`update_one()`, `update_many()`, `replace_once()`, `delete_one()`);
- about some useful Query Operators;
- and hopefully understand the Query Operator syntax as well;
- and as a result you can pinpoint and "slice" more specific queries for data retrieval, document updating and deletion.

#### Requirements
- A working modern computer running macOS, Windows or Ubuntu
- An installed Python 3(.6) distribution, such as (for example) the Anaconda Distribution
- The ambition to learn Python programming

#### Difficulty
Intermediate

#### Curriculum (of the `Learn Python Series`):
- [Learn Python Series - Intro](https://utopian.io/utopian-io/@scipio/learn-python-series-intro)
- [Learn Python Series (#2) - Handling Strings Part 1](https://utopian.io/utopian-io/@scipio/learn-python-series-2-handling-strings-part-1)
- [Learn Python Series (#3) - Handling Strings Part 2](https://utopian.io/utopian-io/@scipio/learn-python-series-3-handling-strings-part-2)
- [Learn Python Series (#4) - Round-Up #1](https://utopian.io/utopian-io/@scipio/learn-python-series-4-round-up-1)
- [Learn Python Series (#5) - Handling Lists Part 1](https://utopian.io/utopian-io/@scipio/learn-python-series-5-handling-lists-part-1)
- [Learn Python Series (#6) - Handling Lists Part 2](https://utopian.io/utopian-io/@scipio/learn-python-series-6-handling-lists-part-2)
- [Learn Python Series (#7) - Handling Dictionaries](https://utopian.io/utopian-io/@scipio/learn-python-series-7-handling-dictionaries)
- [Learn Python Series (#8) - Handling Tuples](https://utopian.io/utopian-io/@scipio/learn-python-series-8-handling-tuples)
- [Learn Python Series (#9) - Using Import](https://utopian.io/utopian-io/@scipio/learn-python-series-9-using-import)
- [Learn Python Series (#10) - Matplotlib Part 1](https://utopian.io/utopian-io/@scipio/learn-python-series-10-matplotlib-part-1)
- [Learn Python Series (#11) - NumPy Part 1](https://utopian.io/utopian-io/@scipio/learn-python-series-11-numpy-part-1)
- [Learn Python Series (#12) - Handling Files](https://utopian.io/utopian-io/@scipio/learn-python-series-12-handling-files)
- [Learn Python Series (#13) - Mini Project - Developing a Web Crawler Part 1](https://utopian.io/utopian-io/@scipio/learn-python-series-13-mini-project-developing-a-web-crawler-part-1)
- [Learn Python Series (#14) - Mini Project - Developing a Web Crawler Part 2](https://utopian.io/utopian-io/@scipio/learn-python-series-14-mini-project-developing-a-web-crawler-part-2)
- [Learn Python Series (#15) - Handling JSON](https://utopian.io/utopian-io/@scipio/learn-python-series-15-handling-json)
- [Learn Python Series (#16) - Mini Project - Developing a Web Crawler Part 3](https://utopian.io/utopian-io/@scipio/learn-python-series-16-mini-project-developing-a-web-crawler-part-3)
- [Learn Python Series (#17) - Roundup #2 - Combining and analyzing any-to-any multi-currency historical data](https://utopian.io/utopian-io/@scipio/learn-python-series-17-roundup-2-combining-and-analyzing-any-to-any-multi-currency-historical-data)
- [Learn Python Series (#18) - PyMongo Part 1](https://utopian.io/utopian-io/@scipio/learn-python-series-18-pymongo-part-1)

# Learn Python Series (#19) - PyMongo Part 2

In the previous `Learn Python Series` episode about `PyMongo Part 1`, we learned - in essence - the difference between SQL and NoSQL databases, and we learned how to setup and interact with MongoDB via Python's PyMongo iwth respect to inserting one or more documents to a collection, finding one or more documents stored in a collection, based on a certain - or empty - search query, and we learned how to count the number of those documents found.

In this episde, we'll expand our knowledge regarding PyMongo with a number of techniques. Let's get started!

# Updating one document using `update_one()` and the `$set` update operator
As a brief reminder, and/or for the people "jumping in" on this `PyMongo Part 2` episode, let's first import pymongo again, establish the connection, assign the database and collection, and take it from there:


```python
import pymongo

# Importing the pretty print module,
# you don't have to, it just formats better
# for readability on Utopian.io / Steemit.com
from pprint import pprint

client = pymongo.MongoClient('mongodb://localhost:27017')
db = client.test_mongo
coll = db.accounts
```

Let's first print the current state the `scipio` document is in, so we clearly know which effect updating it wil have:


```python
scipio = coll.find_one({"account": "scipio"})

# print() instead of pprint() works just fine as well
pprint(scipio)
```

    {'_id': ObjectId('5ae46285dd58330cd666056f'),
     'account': 'scipio',
     'slogan': "Does it matter who's right, or who's left?"}


Now, when looking at https://steemd.com/@scipio I see my Steem Id is `422033` so let's add that to the `scipio` account document, by updating it with `update_one()`:


```python
result = coll.update_one(
    {"account": "scipio"}, 
    {"$set": {"account_id": 422033}}
)

scipio = coll.find_one({"account": "scipio"})
print('Updated Scipio document: {}'.format(scipio))
```

    Updated Scipio document: {'_id': ObjectId('5ae46285dd58330cd666056f'), 'account': 'scipio', 'slogan': "Does it matter who's right, or who's left?", 'account_id': 422033}


**Nota bene 1:** the `update_one()` method first expects a key:value pair argument to find the target document (to be updated) with, then it expects the update query as a second argument.

**Nota bene 2:** the `$set` operator creates the field `"account_id"` if it doesn't exist yet, otherwise it updates it.

# Updating multiple documents using `update_many()`
Suppose we want to update all (currently: 4) documents in the `accounts` collection with the key:value pair `{"active": True}`. The `update_many()` method is perfectly suited to do that. It works as follows:


```python
result = coll.update_many({}, {"$set": {"active": True}})
all_accounts = coll.find()
for each_account in all_accounts:
    pprint(each_account)
```

    {'_id': ObjectId('5ae46285dd58330cd666056f'),
     'account': 'scipio',
     'account_id': 422033,
     'active': True,
     'slogan': "Does it matter who's right, or who's left?"}
    {'_id': ObjectId('5ae46693dd58330cd6660570'),
     'account': 'stoodkev',
     'active': True}
    {'_id': ObjectId('5ae46693dd58330cd6660571'),
     'account': 'fabiyamada',
     'account_id': 261379,
     'active': True}
    {'_id': ObjectId('5ae46693dd58330cd6660572'),
     'account': 'jedigeiss',
     'active': True,
     'slogan': 'IT Nerd, Risk Specialist, Musician, Cryptocoin Enthusiast, Banker, '
               'Gamer'}


# Updating a single document by replacing its content using `replace_one()`
Now let's again have a look at the `jedigeiss` account. Being German, @jedigeiss without a doubt is a huge fan of Matthias Reim's song "Verdammt ich lieb dich" (published in 1994), so let's change his slogan using `replace_once()` like so:


```python
# PS: pymongo (relatively) recently changed the location of
# the objectid class from pymongo to bson.
# If you want to query using ObjectIds, import this as well:
from bson.objectid import ObjectId

new_slogan = "Verdammt ich lieb dich, Ich lieb dich nicht."
result = coll.replace_one({'_id': ObjectId('5ae46693dd58330cd6660572')}, 
                          {"slogan": new_slogan})

jedigeiss = coll.find_one({'_id': ObjectId('5ae46693dd58330cd6660572')})
print(jedigeiss)
```

    {'_id': ObjectId('5ae46693dd58330cd6660572'), 'slogan': 'Verdammt ich lieb dich, Ich lieb dich nicht.'}


**Hmmmm...** the "slogan" value did change to the famous Matthias Rein song, but now the "account" and "active" fields (key:value pairs) are gone!

This is of course not a bug but a feature of the `replace_one()` method: as opposed to the `update_one()` method that leaves the "other" document fields in tact, the `replace_one()` method **replaces** the entire document data with the data passed to it as an argument. Please keep this in mind when using `replace_one()`!

# Deleting a single document with `delete_one()`
Since the accounts document previously containing the data from @jedigeiss now only contains an ObjectId and a slogan from Matthias Rein, we might as well delete that document alltogether. We can do this, like so:


```python
result = coll.delete_one({'_id': ObjectId('5ae46693dd58330cd6660572')})
num_accounts = coll.find().count()
print(num_accounts)
```

    3


And as a result, our `accounts` collection now consists of only 3 accounts.

But... this tutorial episode cannot continue before bringing back my friend and fellow Utopian Advisor @jedigeiss to the database, so let's do so via:


```python
jedigeiss = {
 'account': 'jedigeiss',
 'active': True,
 'slogan': 'IT Nerd, Risk Specialist, Musician, Cryptocoin Enthusiast, Banker, '
           'Gamer'
}

result = coll.insert_one(jedigeiss)
```


```python
all_accounts = coll.find()
for each_account in all_accounts:
    pprint(each_account)
```

    {'_id': ObjectId('5ae46285dd58330cd666056f'),
     'account': 'scipio',
     'account_id': 422033,
     'active': True,
     'slogan': "Does it matter who's right, or who's left?"}
    {'_id': ObjectId('5ae46693dd58330cd6660570'),
     'account': 'stoodkev',
     'active': True}
    {'_id': ObjectId('5ae46693dd58330cd6660571'),
     'account': 'fabiyamada',
     'account_id': 261379,
     'active': True}
    {'_id': ObjectId('5ae4bc73dd58332709589486'),
     'account': 'jedigeiss',
     'active': True,
     'slogan': 'IT Nerd, Risk Specialist, Musician, Cryptocoin Enthusiast, Banker, '
               'Gamer'}


... better!

### Recap: What have we learned thus far regarding PyMongo?

We can now do so-called basic **CRUD operations** using PyMongo:

- C (Create): `insert_one()`, `insert_many()`
- R (Read): `find_one()`, `find_many()`
- U (Update): `update_one()`, `update_many()`, `replace_one()`
- D (Delete): `delete_one()`

# Using Query Operators
Up until now, we've been using very simple queries, either none (to find or update all documents in the collection) or so specific that only one document was found (either by `"account": name` or by ObjectId). But one of the big advantages of MongoDB is its ability to use **Query Operators**, allowing you to define more complex queries for finding, updating and/or deleting documents or fields. Let's review a few well-known and useful Query Operators.

### `$exists`
`$exists` matches documents containing / having **a specific field**, for example the `"slogan"` field, like so:


```python
result = coll.find({"slogan": {"$exists": True}})
for account in result:
    pprint(account)
```

    {'_id': ObjectId('5ae46285dd58330cd666056f'),
     'account': 'scipio',
     'account_id': 422033,
     'active': True,
     'slogan': "Does it matter who's right, or who's left?"}
    {'_id': ObjectId('5ae4bc73dd58332709589486'),
     'account': 'jedigeiss',
     'active': True,
     'slogan': 'IT Nerd, Risk Specialist, Musician, Cryptocoin Enthusiast, Banker, '
               'Gamer'}


or, the other way around, to find all accounts documents **not** having the `"slogan"` field in them:


```python
result = coll.find({"slogan": {"$exists": False}})
for account in result:
    pprint(account)
```

    {'_id': ObjectId('5ae46693dd58330cd6660570'),
     'account': 'stoodkev',
     'active': True}
    {'_id': ObjectId('5ae46693dd58330cd6660571'),
     'account': 'fabiyamada',
     'account_id': 261379,
     'active': True}


### `$gt` and `$gte`, `$lt` and `$lte`
`$gt` matches values greater than ( > ) a specified value, `$gte` matches values greater than or equal to ( >= ) a specified value:


```python
result = coll.find({"account_id": {"$gt": 261379}})
for account in result:
    pprint(account)
```

    {'_id': ObjectId('5ae46285dd58330cd666056f'),
     'account': 'scipio',
     'account_id': 422033,
     'active': True,
     'slogan': "Does it matter who's right, or who's left?"}



```python
result = coll.find({"account_id": {"$gte": 261379}})
for account in result:
    pprint(account)
```

    {'_id': ObjectId('5ae46285dd58330cd666056f'),
     'account': 'scipio',
     'account_id': 422033,
     'active': True,
     'slogan': "Does it matter who's right, or who's left?"}
    {'_id': ObjectId('5ae46693dd58330cd6660571'),
     'account': 'fabiyamada',
     'account_id': 261379,
     'active': True}


`$lt` matches values smaller than ( < ) a specified value, `$lte` matches values smaller than or equal to ( <= ) a specified value:


```python
result = coll.find({"account_id": {"$lt": 422033}})
for account in result:
    pprint(account)
```

    {'_id': ObjectId('5ae46693dd58330cd6660571'),
     'account': 'fabiyamada',
     'account_id': 261379,
     'active': True}



```python
result = coll.find({"account_id": {"$lte": 422033}})
for account in result:
    pprint(account)
```

    {'_id': ObjectId('5ae46285dd58330cd666056f'),
     'account': 'scipio',
     'account_id': 422033,
     'active': True,
     'slogan': "Does it matter who's right, or who's left?"}
    {'_id': ObjectId('5ae46693dd58330cd6660571'),
     'account': 'fabiyamada',
     'account_id': 261379,
     'active': True}


### `$ne`
`$ne` matches documents that are **not equal** to a specified value. Please note that if documents don't contain a specific field at all, that the `$ne` Query Operator matches those non-existent field-documents as well!


```python
result = coll.find({"account_id": {"$ne": 123456}})
for account in result:
    pprint(account)
```

    {'_id': ObjectId('5ae46285dd58330cd666056f'),
     'account': 'scipio',
     'account_id': 422033,
     'active': True,
     'slogan': "Does it matter who's right, or who's left?"}
    {'_id': ObjectId('5ae46693dd58330cd6660570'),
     'account': 'stoodkev',
     'active': True}
    {'_id': ObjectId('5ae46693dd58330cd6660571'),
     'account': 'fabiyamada',
     'account_id': 261379,
     'active': True}
    {'_id': ObjectId('5ae4bc73dd58332709589486'),
     'account': 'jedigeiss',
     'active': True,
     'slogan': 'IT Nerd, Risk Specialist, Musician, Cryptocoin Enthusiast, Banker, '
               'Gamer'}


### `$in` and `$nin`
The `$in` operator allows for passing in a list (array) of values and it then matches any documents containing values  specified in the list (array).


```python
result = coll.find({"account": {"$in": ["stoodkev","scipio", "jedigeiss"]}})
for account in result:
    pprint(account)
```

    {'_id': ObjectId('5ae46285dd58330cd666056f'),
     'account': 'scipio',
     'account_id': 422033,
     'active': True,
     'slogan': "Does it matter who's right, or who's left?"}
    {'_id': ObjectId('5ae46693dd58330cd6660570'),
     'account': 'stoodkev',
     'active': True}
    {'_id': ObjectId('5ae4bc73dd58332709589486'),
     'account': 'jedigeiss',
     'active': True,
     'slogan': 'IT Nerd, Risk Specialist, Musician, Cryptocoin Enthusiast, Banker, '
               'Gamer'}


The `$nin` operator does the opposite: it matches any documents **not** specified in the list (array).


```python
result = coll.find({"account": {"$nin": ["stoodkev","scipio", "jedigeiss"]}})
for account in result:
    pprint(account)
```

    {'_id': ObjectId('5ae46693dd58330cd6660571'),
     'account': 'fabiyamada',
     'account_id': 261379,
     'active': True}


# What did we learn, hopefully?

In this episode, we expanded on our gathered knowledge regarding PyMongo by completing the basic CRUD (Create, Read, Update, Delete) operations, by reviewing the methods `update_one()`, `update_many()`, `replace_one()`, and `delete_one()`. We then looked at a few common so-called "Query Operators" with which we can make somewhat more complex queries in order to find, update or delete documents based.

### Thank you for your time!


<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@scipio/learn-python-series-19-pymongo-part-2">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 23 others
properties (23)
authorscipio
permlinklearn-python-series-19-pymongo-part-2
categoryutopian-io
json_metadata"{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":81598961,"name":"cpython","full_name":"python/cpython","html_url":"https://github.com/python/cpython","fork":false,"owner":{"login":"python"}},"pullRequests":[],"platform":"github","type":"tutorials","tags":["utopian-io","steemdev","steemstem","open-source","python"],"users":["jedigeiss"],"links":["https://utopian.io/utopian-io/@scipio/learn-python-series-intro","https://utopian.io/utopian-io/@scipio/learn-python-series-2-handling-strings-part-1","https://utopian.io/utopian-io/@scipio/learn-python-series-3-handling-strings-part-2","https://utopian.io/utopian-io/@scipio/learn-python-series-4-round-up-1","https://utopian.io/utopian-io/@scipio/learn-python-series-5-handling-lists-part-1","https://utopian.io/utopian-io/@scipio/learn-python-series-6-handling-lists-part-2","https://utopian.io/utopian-io/@scipio/learn-python-series-7-handling-dictionaries","https://utopian.io/utopian-io/@scipio/learn-python-series-8-handling-tuples","https://utopian.io/utopian-io/@scipio/learn-python-series-9-using-import","https://utopian.io/utopian-io/@scipio/learn-python-series-10-matplotlib-part-1","https://utopian.io/utopian-io/@scipio/learn-python-series-11-numpy-part-1","https://utopian.io/utopian-io/@scipio/learn-python-series-12-handling-files","https://utopian.io/utopian-io/@scipio/learn-python-series-13-mini-project-developing-a-web-crawler-part-1","https://utopian.io/utopian-io/@scipio/learn-python-series-14-mini-project-developing-a-web-crawler-part-2","https://utopian.io/utopian-io/@scipio/learn-python-series-15-handling-json","https://utopian.io/utopian-io/@scipio/learn-python-series-16-mini-project-developing-a-web-crawler-part-3","https://utopian.io/utopian-io/@scipio/learn-python-series-17-roundup-2-combining-and-analyzing-any-to-any-multi-currency-historical-data","https://utopian.io/utopian-io/@scipio/learn-python-series-18-pymongo-part-1","https://steemd.com/@scipio","https://utopian.io/utopian-io/@scipio/learn-python-series-19-pymongo-part-2"],"image":["https://cdn.utopian.io/posts/cec1aefe48d5e4ab867572c5230f49626693python_logo.png"],"moderator":{"account":"roj","time":"2018-04-28T21:37:21.789Z","pending":false,"reviewed":true,"flagged":false},"questions":null,"score":null,"total_influence":null,"staff_pick":null,"staff_pick_by":null,"config":{"questions":[{"question":"How many substantial concepts does this tutorial address?","question_id":"tuts-1","answers":[{"answer":"4-5 substantial concepts covered in the tutorial.","answer_id":"tuts-1-a-1","value":10},{"answer":"2-3 substantial concepts covered in the tutorial.","answer_id":"tuts-1-a-2","value":7},{"answer":"1 substantial concept covered in the tutorial.","answer_id":"tuts-1-a-3","value":3},{"answer":"More than 5 substantial concepts covered in the tutorial.","answer_id":"tuts-1-a-4","value":0}]},{"question":"Does the title and the outline of the tutorial properly reflect the content?","question_id":"tuts-2","answers":[{"answer":"Yes, it is very clear.","answer_id":"tuts-2-a-1","value":15},{"answer":"To some extent.","answer_id":"tuts-2-a-2","value":11.5},{"answer":"The title is somewhat misleading and/or the outline is not detailed or informative enough.","answer_id":"tuts-2-a-3","value":4.5},{"answer":"Title and outline are of little or no relevance to the content of the tutorial.","answer_id":"tuts-2-a-4","value":0}]},{"question":"Did the contributor provide supplementary resources, such as code and sample files in the contribution post or a linked GitHub repository?","question_id":"tuts-3","answers":[{"answer":"Yes, exceptional supplementary resources are provided including a relevant github repo/gist.","answer_id":"tuts-3-a-1","value":15},{"answer":"Supplementary resources provided are of high relevance.","answer_id":"tuts-3-a-2","value":12},{"answer":"Contributor provides minimal supplementary resources.","answer_id":"tuts-3-a-3","value":6},{"answer":"No supplementary resources were provided.","answer_id":"tuts-3-a-4","value":0}]},{"question":"Is the tutorial part of a series?","question_id":"tuts-4","answers":[{"answer":"Yes.","answer_id":"tuts-4-a-1","value":10},{"answer":"Yes, but it is the first entry in the series.","answer_id":"tuts-4-a-2","value":7},{"answer":"No, but it works just fine as a stand-alone tutorial.","answer_id":"tuts-4-a-3","value":5},{"answer":"No.","answer_id":"tuts-4-a-4","value":0}]},{"question":"Does the tutorial contain sufficient explanatory visuals?","question_id":"tuts-5","answers":[{"answer":"Yes, the visual components of the post were adequate in quality and quantity.","answer_id":"tuts-5-a-1","value":10},{"answer":"The volume of visual components included was unnecessarily large.","answer_id":"tuts-5-a-2","value":7},{"answer":"The post lacked sufficient visualization to easily learn from the content.","answer_id":"tuts-5-a-3","value":3},{"answer":"No visualization was presented in this contribution.","answer_id":"tuts-5-a-4","value":0}]},{"question":"How unique and/or innovative are the concepts covered in the tutorial?","question_id":"tuts-6","answers":[{"answer":"This was the first time I read about the concepts covered.","answer_id":"tuts-6-a-1","value":10},{"answer":"The concepts covered were innovative and offer some usefulness.","answer_id":"tuts-6-a-2","value":7},{"answer":"I have read several similar ideas and thoughts elsewhere, but this one was of higher quality.","answer_id":"tuts-6-a-3","value":5},{"answer":"Such tutorials can be found online with great ease and the contribution add no value to the open source community.","answer_id":"tuts-6-a-4","value":0}]},{"question":"How would you describe the formatting, language and overall presentation of the post?","question_id":"c-1","answers":[{"answer":"The post is of very high quality.","answer_id":"c-1-a-1","value":10},{"answer":"The post is of decent quality, but not spectacular in any way.","answer_id":"c-1-a-2","value":7},{"answer":"The post is poorly written and/or formatted, but readable.","answer_id":"c-1-a-3","value":3},{"answer":"The post is really hard to read and the content is barely understandable.","answer_id":"c-1-a-4","value":0}]},{"question":"How would you rate the overall value of this contribution on the open source community and ecosystem?","question_id":"c-2","answers":[{"answer":"This contribution brings great and impactful value, and can be used for applications outside the specific project.","answer_id":"c-2-a-1","value":20},{"answer":"This contribution adds significant value to the open source community and ecosystem, or is of critical importance to the specific project.","answer_id":"c-2-a-2","value":16},{"answer":"This contribution adds some value to the open source community and ecosystem or is only valuable to the specific project.","answer_id":"c-2-a-3","value":8},{"answer":"This contribution adds no value to the open source community and ecosystem or the specific project.","answer_id":"c-2-a-4","value":0}]}]}}"
created2018-04-28 19:48:21
last_update2018-04-28 21:37:21
depth0
children13
last_payout2018-05-05 19:48:21
cashout_time1969-12-31 23:59:59
total_payout_value78.066 HBD
curator_payout_value27.011 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length16,192
author_reputation34,229,826,851,736
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries
0.
accountutopian.pay
weight1,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,700,858
net_rshares18,743,744,658,861
author_curate_reward""
vote details (87)
@a-0-0 ·
Hi! I will upvote and resteem your post to my 35,000+ followers if you reply to this comment.
👍🏻 [<b>a-0-0</b>](https://steemit.com/@a-0-0)
properties (22)
authora-0-0
permlinkre-scipio-learn-python-series-19-pymongo-part-2-20180428t194842510z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://steemit.com/@a-0-0"],"app":"steemit/0.1"}
created2018-04-28 19:48:39
last_update2018-04-28 19:48:39
depth1
children0
last_payout2018-05-05 19:48:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length139
author_reputation-4,863,186,238,920
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,700,895
net_rshares0
@chireerocks ·
*In my opinion your knowledge sharing work is really appreciable and i am not in developer field but in my opinion the new developers who are working towards the data protection, these session post is really helpful and this knowledge can bring some beneficial aspects in turn when implemented. Thanks for sharing and wishing you an great day. Stay blessed. 🙂*
properties (22)
authorchireerocks
permlinkre-scipio-learn-python-series-19-pymongo-part-2-20180428t195359337z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-28 19:54:03
last_update2018-04-28 19:54:03
depth1
children0
last_payout2018-05-05 19:54:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length360
author_reputation327,821,690,945,691
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,701,562
net_rshares0
@jedigeiss ·
$0.68
Great series @scipio, there is always something to learn, beginners and pros alike.
Matthias Reim, well, hahahaha. Thanks for setting the data back to my normal self ;)
Keep up the brilliant work!
Jan
👍  
properties (23)
authorjedigeiss
permlinkre-scipio-learn-python-series-19-pymongo-part-2-20180428t202155414z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["scipio"],"app":"steemit/0.1"}
created2018-04-28 20:21:54
last_update2018-04-28 20:21:54
depth1
children2
last_payout2018-05-05 20:21:54
cashout_time1969-12-31 23:59:59
total_payout_value0.666 HBD
curator_payout_value0.011 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length200
author_reputation326,601,261,931,660
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,705,074
net_rshares107,521,805,347
author_curate_reward""
vote details (1)
@scipio · (edited)
Well.... I really do think the slogan "Verdammt ich lieb dich" suits you right! :-)
And... could you do a video of yourself performing better on the guitar than Matthias did?

https://www.youtube.com/watch?v=Cox_VYZuT98
properties (22)
authorscipio
permlinkre-jedigeiss-re-scipio-learn-python-series-19-pymongo-part-2-20180428t202640877z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"image":["https://img.youtube.com/vi/Cox_VYZuT98/0.jpg"],"links":["https://www.youtube.com/watch?v=Cox_VYZuT98"],"app":"steemit/0.1"}
created2018-04-28 20:26:39
last_update2018-04-28 20:26:51
depth2
children1
last_payout2018-05-05 20:26:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length219
author_reputation34,229,826,851,736
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,705,639
net_rshares0
@scipio · (edited)
$1.99
On the score metric "hair coupe" you're already doing slightly better! :P
👍  ,
properties (23)
authorscipio
permlinkre-scipio-re-jedigeiss-re-scipio-learn-python-series-19-pymongo-part-2-20180428t202800508z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-28 20:28:00
last_update2018-04-28 20:36:12
depth3
children0
last_payout2018-05-05 20:28:00
cashout_time1969-12-31 23:59:59
total_payout_value1.498 HBD
curator_payout_value0.493 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length73
author_reputation34,229,826,851,736
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,705,808
net_rshares314,373,494,786
author_curate_reward""
vote details (2)
@lover1 ·
Dear@scipio sir,
It's very helpful post for us. I shall follow you continue.
Thank you very much for share a good post.
👍  
properties (23)
authorlover1
permlinkre-scipio-learn-python-series-19-pymongo-part-2-20180429t052252236z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-29 05:22:57
last_update2018-04-29 05:22:57
depth1
children0
last_payout2018-05-06 05:22:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length119
author_reputation117,277,876,100
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,764,835
net_rshares436,012,356
author_curate_reward""
vote details (1)
@moon-girl ·
another part two, i think its helpfull for programer.
thanky you sir@scipio
properties (22)
authormoon-girl
permlinkre-scipio-learn-python-series-19-pymongo-part-2-20180428t195550875z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-28 19:55:57
last_update2018-04-28 19:55:57
depth1
children0
last_payout2018-05-05 19:55:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length75
author_reputation135,142,926,304
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,701,810
net_rshares0
@mousumimou ·
Resteemit done .I always see your post..
properties (22)
authormousumimou
permlinkre-scipio-learn-python-series-19-pymongo-part-2-20180428t195448196z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-28 19:54:48
last_update2018-04-28 19:54:48
depth1
children0
last_payout2018-05-05 19:54:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length40
author_reputation2,898,342,274,656
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,701,656
net_rshares0
@roj ·
$2.08
The submission is reviewed and approved. Thank you for your contributions to open source community.

I have a question for the update methods, how would we update many values in a subset of a document or documents in a collection, like as we would change the `reviewed` state of many posts in an account or accounts? Should we define a variable like `coll = db.accounts` , but for the subset of the accounts? Or is there a different syntax of `update_many()` to this?   

----------------------------------------------------------------------
Need help? Write a ticket on https://support.utopian.io.
Chat with us on [Discord](https://discord.gg/uTyJkNm).

**[[utopian-moderator]](https://utopian.io/moderators)**
👍  
properties (23)
authorroj
permlinkre-scipio-learn-python-series-19-pymongo-part-2-20180428t215224219z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-04-28 21:52:24
last_update2018-04-28 21:52:24
depth1
children1
last_payout2018-05-05 21:52:24
cashout_time1969-12-31 23:59:59
total_payout_value2.082 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length712
author_reputation12,636,295,215,793
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries
0.
accountutopian.pay
weight1,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,715,236
net_rshares515,750,785,335
author_curate_reward""
vote details (1)
@utopian.tip ·
Hey @roj, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
properties (22)
authorutopian.tip
permlinkre-re-scipio-learn-python-series-19-pymongo-part-2-20180428t215224219z-20180428t231616
categoryutopian-io
json_metadata""
created2018-04-28 23:16:18
last_update2018-04-28 23:16:18
depth2
children0
last_payout2018-05-05 23:16:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length153
author_reputation238,310,597,885
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,723,875
net_rshares0
@santoislam ·
I think this is the best post, 
today I see,  about python. You choose a great content for teaching us.
👍  ,
properties (23)
authorsantoislam
permlinkre-scipio-learn-python-series-19-pymongo-part-2-20180429t091008077z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-29 09:10:06
last_update2018-04-29 09:10:06
depth1
children0
last_payout2018-05-06 09:10:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length103
author_reputation145,193,712,426
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,793,600
net_rshares1,222,292,403
author_curate_reward""
vote details (2)
@tensor ·
Very nice tutorial.  I've been recently using MongoBD more and more recently.  Its nice to see a good little rundown on the technology especially with such a popular programming language.
properties (22)
authortensor
permlinkre-scipio-learn-python-series-19-pymongo-part-2-20180429t033419122z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-04-29 03:34:18
last_update2018-04-29 03:34:18
depth1
children0
last_payout2018-05-06 03:34:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length187
author_reputation87,856,203,149,624
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,752,151
net_rshares0
@touhidalam69 ·
$0.09
hello, @scipio
I am dotnet programmer, Seems it will be easy for me to learn python.
Actually your Presentation inspired me...
👍  , , , ,
properties (23)
authortouhidalam69
permlinkre-scipio-learn-python-series-19-pymongo-part-2-20180429t123604006z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-04-29 12:36:06
last_update2018-04-29 12:36:06
depth1
children0
last_payout2018-05-06 12:36:06
cashout_time1969-12-31 23:59:59
total_payout_value0.092 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length126
author_reputation2,409,777,621,558
root_title"Learn Python Series (#19) - PyMongo Part 2"
beneficiaries
0.
accountutopian.pay
weight1,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,821,376
net_rshares23,195,441,048
author_curate_reward""
vote details (5)