Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pretty printing of output in pymongo

I am using pymongo driver to work with Mongodb using Python. Every time when I run a query in python shell, it returns me some output which is very difficult to understand. I have used the .pretty() option with mongo shell, which gives the output in a structured way.

I want to know whether there is any method like pretty() in pymongo, which can return output in a structured way ?

like image 770
Koushik Avatar asked Dec 28 '15 12:12

Koushik


1 Answers

I want to know whether there is any method like pretty() in PyMongo

No PyMongo doesn't provide such method. It is only available in the shell. You need to use the pprint function from the pprint module.

like image 60
styvane Avatar answered Oct 11 '22 00:10

styvane