OneCompiler

too many positional arguments error while doing mongoexport

I am trying to export MongoDB data as a CSV using mongoexport and following is my query

$ mongoexport --db foo --collection bar --csv --out bar.csv  --query={country : "US"}

I am getting the following error while I am doing this

2019-10-24T12:07:15.621+0530	too many positional arguments: [: US}]

1 Answer

6 years ago by

You need to put your query in single quotes. Please refer the following

-- $ mongoexport --db foo --collection bar --csv --out bar.csv  --query={country : "US"}
++ $ mongoexport --db foo --collection bar --csv --out bar.csv  --query='{country : "US"}'
6 years ago by Karthik Divi