3주차 DB 부분을 복습하였다.
오늘 프로젝트 진행을 위해 필요한 코드는 다음과 같다.
from pymongo import MongoClient client = MongoClient('localhost', 27017) db = client.dbsparta //import doc = {'name':'bobby','age':21} //document setting db.users.insert_one(doc) //put document into DB list(db.users.find({'age':21},{'_id':False})) //find ingredients db.users.find_one({'name':'bobby'}) //find one ingredient db.users.update_one({'name':'bobby'},{'$set':{'age':19}}) //undate ingredient db.users.delete_one({'name':'bobby'}) //delete ingredient
이번 팀 프로젝트에서 백엔드를 담당했다.
우리 프로젝트 주제는 세계 유명 도시들의 하늘 사진을 보여주는 페이지이며, 코로나로 인해 여행을 못가는 상황에서 조금이나마 사진으로 대리만족(?)을 하고자 만드는 것이다!
오늘은 시간과 도시의 DB를 추가했다.
pymongo 라이브러리를 설치하고, 각 국가들의 document를 만들었다.
이후에 시간과 도시의 정보를 받아서 해당 조건의 하늘 사진을 띄우게 할 계획이다!
doc_city = {'country':['korea','italy','maldives','mexico','thai', 'spain','canada','america','greece','turkey', 'russia','china','newzealand','philippines','france', 'germany','africa','saudi','antarctica','arctic']} db.sky_for_u.insert_one(doc_city)