我尝试从pycharm(使用RDP)远程连接到mongodb服务器。这是我运行的函数:
cluster = MongoClient("mongodb://admin:Passw0rd!@147.234.32.246:27017/NEG")
db = cluster["NEG"]
for word in Setting.dictionary_global.keys():
if word in db.list_collection_names():
collection = db[word]
for file in Setting.dictionary_global[word].keys():
if collection.find({"url":Setting.dictionary_global[word][file].url}):
continue
num_of_appearance = len(Setting.dictionary_global[word][file].indexes.get(word))
post = {"url": file, "title": Setting.dictionary_global[word][file].title,
"description": Setting.dictionary_global[word][file].description,"word in page": Setting.dictionary_global[word][file].indexes,"appearance": num_of_appearance, "date modified": Setting.dictionary_global[word][file].time}
collection.insert_one(post)
else:
collection = db.create_collection(word)
for file in Setting.dictionary_global[word].keys():
#print(Setting.dictionary_global)
num_of_appearance = len(Setting.dictionary_global[word][file].indexes.get(word))
post = {"url": file, "title": Setting.dictionary_global[word][file].title,
"description": Setting.dictionary_global[word][file].description,"word in page": Setting.dictionary_global[word][file].indexes, "appearance": num_of_appearance, "date modified":Setting.dictionary_global[word][file].time}
collection.insert_one(post)我得到了这个错误:
“”“
回溯(最近一次调用):文件"C:/Users/edend/PycharmProjects/pythonProject11/main.py",行118,在crawler.start()文件"C:\Users\edend\PycharmProjects\pythonProject11\DB.py",行110中,在start insertDB()文件"C:\Users\edend\PycharmProjects\pythonProject11\venv\lib\site-packages\pymongo\database.py",行10中,如果word在db.list_collection_names()中,则在insertDB中:文件db.list_collection_names行863,in list_collection_names for result in self.list_collections(session=session,**kwargs)]文件返回行825,在list_collections return self.__client._retryable_read(文件返回行1460,在文件服务器= self._select_server(文件"C:\Users\edend\PycharmProjects\pythonProject11\venv\lib\site-packages\pymongo\mongo_client.py",行1278,在_select_server服务器= topology.select_server(server_selector)文件服务器行241中,在select_server return random.choice(self.select_servers(选择器,File "C:\Users\edend\PycharmProjects\pythonProject11\venv\lib\site-packages\pymongo\topology.py",行199,in select_servers server_descriptions = self._select_servers_loop(文件提升行215,in _select_servers_loop raise ServerSelectionTimeoutError( pymongo.errors.ServerSelectionTimeoutError: 147.234.32.246:27017:超时,超时: 30s,拓扑描述:>
“”“
请帮我把我卡住,我什么都试一试,谢谢!!
发布于 2021-01-06 01:23:12
常见原因:
running
https://stackoverflow.com/questions/65572587
复制相似问题