I'm trying to upload a .json file to my db with mongoimport. i'm using this chain of commands (without the sensitive info):
mongoimport <host uri that starts with: mongodb srv://...> --authenticationDatabase "admin" --authenticationMechanism= "SCRAM-SHA-1" --collection "..." --file "C:\Users\Jose Miguel\Documents\tinto programa\tinto-programas-3\database\DATA\JSON\2022\JUNIO\JUNIO 2022.json" --username "..." --password "...."
The complete error is the following:
error parsing command line options: error parsing positional arguments: cannot use both --file and a positional argument to set the input file
what could be wrong? i've already read the documentation and everything seems to be in its right place.
EDIT: as per @Joe suggestions, I have edited my command chain to look like this:
mongoimport <connection string, now without quotes> --authenticationMechanism "SCRAM-SHA-1" --authenticationDatabase=admin --collection=<collection_name> --file "C:\Users\Jose Miguel\Documents\tinto programa\tinto-programas-3\database\DATA\JSON\2022\JUNIO\JUNIO 2022.json" --username=<...> --password=<...>
CodePudding user response:
A positional argument is one that is separated from the rest of the command by whitespace, and not introduced with a preceding option that starts with a dash.
Mongoimport can take at most 2 positional arguments: a connection string and a file
Check <host uri that starts with: mongodb srv://...>
, if there are any spaces or shell-reactive characters, escape and/or quote the string
Many of the options to mongoimport can use either =
or space to separate the option from its argument, however --authenticationMechanism= "SCRAM-SHA-1"
may be interpreted as an empty string for auth mechanism, with "SCRAM-SHA-1" as a positional argument. Use either --authenticationMechanism="SCRAM-SHA-1"
or --authenticationMechanism "SCRAM-SHA-1"