Skip to content

Commit 302adb5

Browse files
authored
Merge pull request #13 from talkpython/master
Refresh a few of the docs and a small bit of the code for recent changes
2 parents 76f84f4 + b3075da commit 302adb5

File tree

11 files changed

+64
-17
lines changed

11 files changed

+64
-17
lines changed

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
[![](https://raw.githubusercontent.com/mikeckennedy/mongodb-for-python-for-developers/master/readme_resources/mongo-course-sm.jpg)](https://training.talkpython.fm/courses/explore_mongodb_for_python_developers_course/mongodb-for-python-for-developers-featuring-orm-odm-mongoengine)
44

5+
## Downloading tools
6+
7+
See the [tools-downloads.md](./tools-downloads.md) file for locating the latest tools and apps for this course.
58

69
## Course Summary
710

Diff for: data/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ If you are using an authenticated connection on another server, this more verbos
1212
mongorestore -u admin -p <mypassword> --authenticationDatabase 'admin' --ssl --host <my_hostname> --sslCAFile mongod.crt --sslPEMKeyFile mongod.pem --drop --db DATABASE /path/to/unziped/dir
1313
```
1414

15-
Note this references this two MongoDB certifications for connecting. You can altermantively use the `--sslAllowInvalidCertificates` flag to ignore them.
15+
Note this references this two MongoDB certifications for connecting. You can alternatively use the `--sslAllowInvalidCertificates` flag to ignore them.

Diff for: requirements.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pymongo
2+
mongoengine
3+
faker
4+
python-dateutil # for DateTimeField parsing

Diff for: requirements.txt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# This file is autogenerated by pip-compile with python 3.10
3+
# To update, run:
4+
#
5+
# pip-compile requirements.in
6+
#
7+
faker==15.0.0
8+
# via -r requirements.in
9+
mongoengine==0.24.2
10+
# via -r requirements.in
11+
pymongo==4.2.0
12+
# via
13+
# -r requirements.in
14+
# mongoengine
15+
python-dateutil==2.8.2
16+
# via
17+
# -r requirements.in
18+
# faker
19+
six==1.16.0
20+
# via python-dateutil

Diff for: src/05_pymongo/play_around_pymongo/program.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55

66
db = client.the_small_bookstore
77

8-
# NOTE: In the video we use db.books.count(), it's been deprecated for more explicit
9-
# versions. See
10-
# https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.estimated_document_count
8+
# NOTE: In the video we use db.books.count(), it's been deprecated for more explicit versions. See
9+
# https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.count_documents
1110
# for details
12-
13-
if db.books.estimated_document_count() == 0:
11+
if db.books.count_documents({}) == 0:
1412
print("Inserting data")
1513
# insert some data...
1614
r = db.books.insert_one({'title': 'The third book', 'isbn': '73738584947384'})
@@ -24,7 +22,13 @@
2422
# # print(book, type(book))
2523
# # book['favorited_by'] = []
2624
# book['favorited_by'].append(100)
25+
26+
# Updated from recording, was:
2727
# db.books.update({'_id': book.get('_id')}, book)
28+
#
29+
# pymongo now requires update_one with the $set operator:
30+
# db.books.update_one({'_id': book.get('_id')}, {"$set": book})
31+
2832
# book = db.books.find_one({'isbn': '73738584947384'})
2933
# print(book)
3034

Diff for: src/07_mongoengine/service_central_starter/.idea/dictionaries/screencaster.xml

-7
This file was deleted.

Diff for: src/08_perf/big_dealership/db_stats.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ def main():
2121
print("Each car has an average of {:.2f} service records.".format(service_histories / len(cars)))
2222

2323

24-
main()
24+
if __name__ == '__main__':
25+
main()

Diff for: src/08_perf/big_dealership/q_and_a.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def timed(msg, func):
1010
func()
1111

1212
dt = datetime.now() - t0
13-
print("{} Time: {:,.3f} ms".format(msg, dt.total_seconds() * 1000.0), flush=True)
13+
print("{} Time: {:,.0f} ms".format(msg, dt.total_seconds() * 1000.0), flush=True)
1414

1515

1616
mongo_setup.init()

Diff for: src/08_perf/starter_big_dealership/db_stats.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ def main():
2121
print("Each car has an average of {:.2f} service records.".format(service_histories / len(cars)))
2222

2323

24-
main()
24+
if __name__ == '__main__':
25+
main()

Diff for: src/08_perf/starter_big_dealership/q_and_a.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def timed(msg, func):
1010
func()
1111

1212
dt = datetime.now() - t0
13-
print("{} Time: {:,.3f} ms".format(msg, dt.total_seconds() * 1000.0), flush=True)
13+
print("{} Time: {:,.0f} ms".format(msg, dt.total_seconds() * 1000.0), flush=True)
1414

1515

1616
mongo_setup.init()

Diff for: tools-download.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Tools Downloads
2+
3+
Since the recording, some tool's download locations have changed. Use this list to locate the newest edition
4+
or find the new location of that tool.
5+
6+
# mongo binary (mongo.exe on Windows)
7+
8+
The mongo application/shell has been deprecated and a slightly better version called `mongosh` replaces it.
9+
`mongosh` is largely the same other than the command to run it now is `mongosh` rather than `mongo` of course.
10+
11+
You can download `mongosh` as part of the [**MongoDB Shell**](https://www.mongodb.com/try/download/shell)
12+
download from their website.
13+
14+
# Robomongo
15+
16+
Robomongo was acquired by Studio3T. It's official name was changed to Robo3T and just recently the download
17+
location was removed from the website. But you can still download the exact same file from the GitHub repository:
18+
19+
https://github.com/Studio3T/robomongo/releases
20+
21+
(Open source for the win). Find your platform's version there and download it.

0 commit comments

Comments
 (0)