python - 如何使用 Jupyter 笔记本从 Watson Studio 连接到 MongoDB
问题描述
我想使用 Python 环境从 watson studio 连接到 MongoDB,我尝试了下面的代码
MONGO_HOST = "xxxxxxxxx" # hostname
MONGO_PORT = 30325
MONGO_DB = "test"
MONGO_USER = "xxxx"
MONGO_PASS = "xxxxxxxx"
con = pymongo.MongoClient(MONGO_HOST, MONGO_PORT)
db = con[MONGO_DB]
db.authenticate(MONGO_USER, MONGO_PASS)
然后我得到了这个错误: ServerSelectionTimeoutError: connection closed,connection closed,connection closed, Timeout: 30s, Topology Description: <TopologyDescription id: 60c72c0d8b3ca9554ba1ba19, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('hostname', 30325) server_type: Unknown, rtt:无,错误=AutoReconnect('连接关闭')>,<ServerDescription('80eef57e-dc80-47b1-a0bc-0b674d206d21-1.c0v4phir0ah9ul9trho0.databases.appdomain.cloud',30325)server_type:未知,rtt:无, error=AutoReconnect('connection closed')>, <ServerDescription ('hostname', 30325) server_type: Unknown, rtt: None, error=AutoReconnect('connection closed')>]>
解决方案
推荐阅读
- qt - QML 进度条未显示在 UI 上
- math - 给定许多矩形,按行分组的最佳方法是什么
- bioinformatics - 将 .gprobs 文件从 Impute2 转换为 PLINK 格式时出错
- subprocess - Python subprocess.check_output()
- android - 没有使用 google api 获取任何照片
- c# - 如何通过ajax或html数据从存储过程中传递项目列表
- linux - 无法使用期望在远程服务器中通过 sftp 输入所有文件
- python-3.x - Python:创建新列并从其他行复制值,这是当前行的交换
- algorithm - 以子集元素和的升序生成多重集的子集
- actions-on-google - Google 助理找不到我的 Google Action