
Python 스크립트를 사용하여 pymongo 드라이버를 사용하기 위한 데이터베이스와 컬렉션을 만들고 싶습니다. 하지만 데이터베이스를 만들 수는 없습니다.
내가 따랐던 단계:
from pymongo import MongoClient
con = MongoClient('localhost', 27017)
db = con.testdb
이 명령을 실행한 후 mongoshell을 체크인하면 "testdb" 데이터베이스가 생성되지 않습니다.
paramiko를 사용하여 mongo 셸과 상호 작용할 수 있나요?
파이썬 버전: 2.7
답변1
~에서http://api.mongodb.com/python/current/tutorial.html
그것은 상태
An important note about collections (and databases) in MongoDB is that
they are created lazily - none of the above commands have actually
performed any operations on the MongoDB server. **Collections and
databases are created when the first document is inserted into them.**