I want to import a CSV file into a specific scope and collection within a bucket, in CB 7.0 enterprise using cbimport
. The command shown in the Web UI is limited to specifying the bucket using the -b
flag.
Is there any way I could import to a specific collection only(except _default
) using cbimport? I’m looking for the cbimport
equivalent of importing using the Web UI where scope and collection are specified.
Hi,
You can supply the --scope-collection-exp
flag to cbimport to import to a specific collection, the flag accepts a collection string of the format ‘scope_name.collection_name’.
For example, given the following csv file ‘people.csv’:
fname,age
alice,40
barry,36
You can import it into my_scope.my_collection in my_bucket using the following command:
/opt/couchbase/bin/cbimport csv -g %fname% -d file://people.csv -c 10.112.210.101 -u Administrator -p password -b my_bucket --scope-collection-exp 'my_scope.my_collection'
Kind regards,
Asad
1 Like