I want to run the same query for all databases
`
for example
import pymongo
db = pymongo.MongoClient("localhost")
db["*"]["test"].find()
or
import pymongo
db = pymongo.MongoClient("localhost")
db["db1","db2","db3"]["test"].find()
To put it bluntly, how to run this logic in mongodb
import pymongo
db = pymongo.MongoClient("localhost")
db_names = db.list_database_names()
for x in db_names:
db[x]["test"].find()
.find()queries in your example are empty, are you trying to export data or are you looking to find a value and don't know what collection it is in?$unionWith) it is possible to query multiple collections within the same database at once, but nothing across databases.