Files
FilesReadSystem/backend/test/MongoDBConnectionTest.py

12 lines
271 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from pymongo import MongoClient
# 连接 MongoDB带认证
client = MongoClient('mongodb://admin:20060825fhy.@kronecker.cc:27017/admin')
# 切换到 test 数据库
db = client.test
print(db.name)
# 正确的列出集合的方法
print(db.list_collection_names())