일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- nestjs
- puppeteer
- java
- 인접리스트
- 코딩테스트
- dfs
- OOP
- winston
- LifeCycle
- Spring
- Kubernetes
- html
- GraphQL
- Interceptor
- Linux
- Deep Dive
- javascript
- TIL
- 알고리즘
- 자료구조
- REST API
- JWT
- MySQL
- 프로그래머스
- node.js
- css
- 인접행렬
- typescript
- 탐욕법
- bean
- Today
- Total
처음부터 차근차근
MongoDB 사용법 본문
No-SQL에서 자주쓰이는 MongoDB를 사용해볼려고 한다.
MongoDB의 경우, pymongo, dnspython을 install해야 한다.
먼저 MongoDB 주소는
https://cloud.mongodb.com/v2#/org/644a66aefe054320dc8835aa/projects
Cloud: MongoDB Cloud
account.mongodb.com
주소로 들어간 뒤, MongoDB의 application code을 가지고 와야 한다.
Connect 클릭 후 Driver 클릭 후 Python 버전 확인 후 Application Code를 가지고 온다.
이후 pymongo 기본 코드를 입력
URL 입력 칸에 Application Code를 입력한다.
예시로,
mongodb+srv://sparta:<password>@cluster0.iak8atg.mongodb.net/?retryWrites=true&w=majority
<password> 항목에는 삭제하고 password가 들어가야 한다.
주로 사용하는 코드는
해당하는 항목에 넣어두었으며, 그때마다 복붙하면 된다.
MongoDB에 데이터가 잘 들어왔는지 확인해볼려면
- Brower Collections 버튼 클릭 - Collection 탭 클릭 후 해당 db에 들어가 데이터가 있는지 확인 및 수정이 가능하다.
추가적인 방법은 아래 문서를 참조하자
https://pymongo.readthedocs.io/en/4.1.1/tutorial.html
Tutorial — PyMongo 4.1.1 documentation
Tutorial This tutorial is intended as an introduction to working with MongoDB and PyMongo. Prerequisites Before we start, make sure that you have the PyMongo distribution installed. In the Python shell, the following should run without raising an exception
pymongo.readthedocs.io