【以下的问题经过翻译处理】 我正在尝试获取我的DocumentDB的数据库名称列表。我正在使用pymongo库。
我运行了这段代码;
logging.info("get client")
#connectionString = os.environ["documentdb_connection"]
connectionString = "mongodb://geoff:qzmpqzmp@docdb-2023-03-22-20-49-15.cluster-cwl5gnwixa5k.us-east-1.docdb.amazonaws.com:27017/?ssl=true&ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false"
##Specify the database to be used
logging.info("Get database testdb")
#db = client.testdb
logging.info("All the databases")
#db = client.testdb
logging.info(client.list_database_names())
我无法连接到我想要的特定数据库,因此我打算注释掉那些行,而是列出所有的数据库,以检查它是否存在。在代码的最后一行中,我得到一个NameError; “name'client'未定义”
我该怎么办?