Computer Programming/Python
2023. 5. 12.
[Python] pymongo, dnspython ํ๋ ์์ํฌ๋ฅผ ์ด์ฉํ insert | find | update | delete ์ฝ๋
# ์ ์ฅ - ์์ doc = {'name':'bobby','age':21} db.users.insert_one(doc) # ํ ๊ฐ ์ฐพ๊ธฐ - ์์ user = db.users.find_one({'name':'bobby'}) # ์ฌ๋ฌ๊ฐ ์ฐพ๊ธฐ - ์์ ( _id ๊ฐ์ ์ ์ธํ๊ณ ์ถ๋ ฅ) all_users = list(db.users.find({},{'_id':False})) # ๋ฐ๊พธ๊ธฐ - ์์ db.users.update_one({'name':'bobby'},{'$set':{'age':19}}) # ์ง์ฐ๊ธฐ - ์์ db.users.delete_one({'name':'bobby'})