如何通过python连接mongodb bi连接器?

问题描述 投票:0回答:0

如何通过python连接mongodb bi连接器? pymongo 可以吗?如果是,请提供一些 authMechanism PLAIN(LDAP) 的示例?

我曾尝试连接 pymongo,但似乎它不适用于 mongodb bi 连接器,因为它返回错误“得到响应 id xxxxxxxxxx 但预期 xxxxx”。

我尝试过的代码

from pymongo import MongoClient

# Replace 'localhost' with the hostname or IP address of your BI 
Connector server
host = 'localhost'
port = 27017  # Default port for MongoDB

# Connect to the MongoDB BI Connector without specifying username 
and password
mongo_uri = f"mongodb://{host}:{port}/"
client = MongoClient(mongo_uri)

# Now you can use the 'client' object to interact with the 
MongoDB BI Connector
# For example, you can access databases and collections like 
this:
db = client['your_database_name']
collection = db['your_collection_name']

# Perform your operations on the collection here

我用 Mongo db bi 连接器替换了主机名和端口,该连接器在 java 中工作但无法工作,此代码为 MongoDB 做了什么。

MongoDB和MongoDB bi连接器使用相同的方式连接吗? 或者有什么我可以遵循的文档吗? (我在pymongo官网没有找到)

python mongodb pymongo mongodb-biconnector
© www.soinside.com 2019 - 2024. All rights reserved.