tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 No SQL > Mongo DB > How to export database collection to CSV or JSON

How to export database collection to CSV or JSON 

MongoDB is a scalable, high-performance, open source NoSQL database. It offers Ad hoc queries, Indexing, Replication, Load balancing, File storage (GridFS), Aggregation, MapReduce and Server-side JavaScript execution. A single mongod process runs on one machine, and can host many databases. Each database can have many Collections (Can say "tables" in RDBMS language). The following example shows how to export a Collection using mongoexport utility.

mongoexport -d mytestdb -c students
mongoexport -d mytestdb -c students -f  name,age
mongoexport -d mytestdb -c students -f  name,age --csv


	-d [ --db ] arg             The database to use
	-c [ --collection ] arg     The Collection to export
	-f [ --fields ] arg         Comma separated list of fields to export
	--csv                       Exports the contents of Collection as CSV instead of JSON.


bl  br