Python 如何在mongodb中的db.runCommand中将集合名称作为变量传递

Python 如何在mongodb中的db.runCommand中将集合名称作为变量传递,python,mongodb,Python,Mongodb,在python中,我对查询使用聚合,并使用db.runCommand进行查询。问题是我想插入变量集合名称,而不是它的实际名称。 假设集合名称为xyz collec = 'xyz' func_(collec) 现在在我使用的另一个文件中 def func_(collection1): data = db.runCommand('aggregate', 'collection1', pipeline=pipe) 那么如何在这个db.runCommand中使用这个collectio

在python中,我对查询使用聚合,并使用db.runCommand进行查询。问题是我想插入变量集合名称,而不是它的实际名称。 假设集合名称为xyz

 collec = 'xyz'
 func_(collec)
现在在我使用的另一个文件中

 def func_(collection1):
     data = db.runCommand('aggregate', 'collection1', pipeline=pipe)
那么如何在这个db.runCommand中使用这个collection1而不是xyz呢

def func_(collection1):
    data = db.runCommand('aggregate', collection1, pipeline=pipe)

是的,我希望它是这样的,但集合的实际名称是xyz,所以只需调用函数,如
func_uz(“xyz”)