Couchbase Commandline utility: CBC N1QL

n1ql statement using cbc doesn’t accept variable from shell

shell parameters:

cbc n1ql ‘update $bucket USE KEYS “$7” set $ = “$4”, $3.port =’$5’ returning $bucket.*’ -U $cb_url -P $pass

my goal is to be able to update existing documents through commandline from a remote server. any ideas how to achieve this?

I have not tried shell, but you can use rest api for CURD operation.
Write shell script which does curl operations

In addition to @nihar.rathod’s suggestion, you may want to look at invoking cbq through the command line.

Or you might want to look at writing a simple program in Python, which can be invoked like a shell command.

btw shell does not interpolate single quotes

You can use the --file option in cbq we shipped with Couchbase 4.5.


/cc @isha

Thanks folks! i’ve written simple python for update and so far i was able to pass values from main shell script.

I should have made it clear what i meant by “update”. Last two functionality i am trying to achieve then i am done :slight_smile:

  1. I would like to be able to add some attribute on an existing document
  2. edit an existing attribute

The values required on the “update” will be provided by user as parameter

my doc looks like this

“type”: “address”,
“DEV1”: {
“port”: “43000”,
“host”: “
“PT2”: {
“port”: “42000”,
“host”: “
“ST2”: {
“port”: “52000”,
“host”: “