John Prawyn
John Prawyn

Reputation: 1693

db.getCollectionNames() equivalent in pymongo

mongodb db.getCollectionNames()command will give you all collection names what are all there in the current db, in a list.

I want the same output using pymongo. I googled some time and couldn't find anything like that.

Is anything like that exists ?

Upvotes: 6

Views: 9614

Answers (2)

Tzach
Tzach

Reputation: 13406

Since pymongo 3.7, collection_names() is deprecated and the correct way to get collection names is list_collection_names()

Upvotes: 3

Ionică Bizău
Ionică Bizău

Reputation: 113517

 collection_names()

Will show you the collections of the current database.

From documentation:

collection_names()

Get a list of all the collection names in this database. [read more]

Upvotes: 8

Related Questions