물론 나는 데이터의 세부 사항에 대해서는 확실하지 않지만, 이것은 pymongo
을 사용하여 MongoDB와 상호 작용하는 일반적인 흐름입니다.
import json
from pymongo import MongoClient
# Create a connection to the mongodb instance. Passing no parameters will connect to default host (localhost) and port (27017)
connection = MongoClient()
# Store the database reference in a variable
db = connection.bloomberg
# Get the collection
collection = db.<whatever-you-want-the-collection-name-to-be>
# Assuming the response of the API is a json string in a variable line
collection.insert(json.loads(line))
JSON 문서를 MongoDB 컬렉션에 저장하는 방법입니다. MongoDB 컬렉션에서 데이터를 가져 오는 것은 간단하며, documentation이 그것에 대해 이야기 할 것이라고 확신합니다.