2017-05-07 100 views
1

這裏是我的代碼:pymongo DB已與不同的情況下,存在已經有

from pymongo import MongoClient 
from pprint import pprint 
from collections import OrderedDict 
import operator 
client = MongoClient() 
client = MongoClient('localhost', 27017) 
db = client['searchPo'] 

db.video.create_index([("'video_id", 1),("unique", 1), ("dropDups" , 1)]) 

和我得到這個錯誤:

db already exists with different case already have: [searchPo] trying to create [searchpo] 

而且我不明白爲什麼我的 數據庫的名稱是searchPo並且沒有其他數據庫

感謝和問候

回答

1

​​,「數據庫名稱不能僅在字符的情況下不同。」您已經創建了一個名爲「searchpo」的數據庫,並且您試圖在名爲「searchPo」的數據庫中用大寫字母「P」在集合「video」上創建一個索引。通常情況下,當你在數據庫的集合上創建一個索引時,MongoDB會自動創建一個數據庫,但在這裏,由於已經有一個小寫字母「p」的「searchpo」數據庫,它會拒絕。

替換此行:

db = client['searchPo'] 

與此:

db = client['searchpo'] 
相關問題