MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Come posso usare pymongo per connettermi a una raccolta/db di documenti esistente?

Connettiti a un database esistente

import pymongo
from pymongo import MongoClient
connection = MongoClient()
db = connection.mydatabase

Elenca i database esistenti

import pymongo
from pymongo import MongoClient
connection = MongoClient()
# connection.database_names() # depreciated
connection.list_database_names()