I am attempting to store the name of a MongoDB collection in a variable and refer to that in a query. If I specify the name of the collection without quotes, my query runs, but if I place the name of my collection in a variable as a string, my query will not run.
Here is what I am trying to run. As mentioned, when "x" is replaced with P38, the query produces results, but does not produces results in its current form.
x = 'P38'cursor = db.x.find({})for item in cursor: print(item)