Week3 Quiz2.
For this quiz, create a file named dbmovie.py and start with the code below.
from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:sparta@cluster0.grgzlle.mongodb.net/?retryWrites=true&w=majority')
db = client.dbsparta
Quiz1. What's the review point of '가버나움'?

when looking for a certain data, use
user = db.users.find_one({'name':'bobby'})
Print(movie)first.
from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:sparta@cluster0.grgzlle.mongodb.net/?retryWrites=true&w=majority')
db = client.dbsparta
movie = db.movies.find_one({'title':'가버나움'})
print(movie)

- We only need 'star'
from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:sparta@cluster0.grgzlle.mongodb.net/?retryWrites=true&w=majority')
db = client.dbsparta
movie = db.movies.find_one({'title':'가버나움'})
print(movie['star'])

Quiz2. Show me all the movie titles that have the same review score as 가버나움.

- define
star
from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:sparta@cluster0.grgzlle.mongodb.net/?retryWrites=true&w=majority')
db = client.dbsparta
movie = db.movies.find_one({'title':'가버나움'})
star = movie['star']
- To find all data, use
all_users = list(db.users.find({},{'_id':False}))
all_movies = list(db.movies.find({'star':star},{'_id':False}))
- use
forstatement and print.
from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:sparta@cluster0.grgzlle.mongodb.net/?retryWrites=true&w=majority')
db = client.dbsparta
movie = db.movies.find_one({'title':'가버나움'})
star = movie['star']
all_movies = list(db.movies.find({'star':star},{'_id':False}))
for m in all_movies:
print(m)

- As a result, we want to see only the titles.
from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:sparta@cluster0.grgzlle.mongodb.net/?retryWrites=true&w=majority')
db = client.dbsparta
movie = db.movies.find_one({'title':'가버나움'})
star = movie['star']
all_movies = list(db.movies.find({'star':star},{'_id':False}))
for m in all_movies:
print(m['title'])

Quiz3. Make the review point of 가버나움 0.

- To update data, use
db.users.update_one({'name':'bobby'},{'$set':{'age':19}})
db.movies.update_one({'title':'가버나움'},{'$set':{'star':'0'}})
from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:sparta@cluster0.grgzlle.mongodb.net/?retryWrites=true&w=majority')
db = client.dbsparta
db.movies.update_one({'title':'가버나움'},{'$set':{'star':'0'}})