Error in Usage of ./cbq options

Hi

I am a newbie to Couchbase
while operating on ./cbq
\EXIT and \QUIT to exit from the apart from the Ctrl+D i am getting below errors.can anyone please help

cbq> \EXIT

;
{
“requestID”: “7a38e932-9bc2-436d-80ce-7dd0320bc58c”,
“errors”: [
{
“code”: 3000,
“msg”: “Input was not a statement.”
}
],
“status”: “fatal”,
“metrics”: {
“elapsedTime”: “512.712µs”,
“executionTime”: “462.336µs”,
“resultCount”: 0,
“resultSize”: 0,
“errorCount”: 1
}
}

cbq> \QUIT;
{
“requestID”: “aabdcb4f-fb1a-4427-b282-40fdf7b90e8e”,
“errors”: [
{
“code”: 3000,
“msg”: “Input was not a statement.”
}
],
“status”: “fatal”,
“metrics”: {
“elapsedTime”: “441.463µs”,
“executionTime”: “394.438µs”,
“resultCount”: 0,
“resultSize”: 0,
“errorCount”: 1
}
}

Hi,

It looks like you are using the older version of the shell. Can you confirm what version you are using ?

Can you try the \version command ? If that doesn’t give you an output, you are using the older version.

cbq> \version;
SHELL VERSION : 1.5

Thanks

2 Likes

Thanks, isha .it will be a great help for me can you please tell how to update it to the latest version .

Thanks
Narendra

Hi Narendra,

If you download the latest release, you should have the new shell (cbq).

Thanks
Isha

1 Like

Thanks isha for the solution .I am now using couchbase4.1 where i want to scedule daily cleanup job using scripting on couch base by using following N1Ql queries how can i do that in couchbase 4.1 through cbq ?

DELETE FROM tutorial t WHERE t.title = “Mrs”

You can use curl and cron. See N1QL REST API and curl usage.

Hi @narendra.puchakayala,
There are a couple of options for that.

  1. Like Gerald suggested, use curl commands in a file and run them.
  2. Use cbq : Using File handling options in cbq

-> Create a cleanup.sql file with your cleanup n1ql commands.
For example
Inside sample.sql

delete from tutorial t … ;
delete from … ;


Then when you call cbq as follows ./cbq -e= -f=sample.sql
This will run the commands in the file and execute them.

You can also invoke this during a session using the \SOURCE sample.sql;
shell command.

Thanks

Also here is a link to the N1QL REST API documentation.
http://developer.couchbase.com/documentation/server/4.5/n1ql/n1ql-rest-api/index.html

As @geraldss suggested, you can use the examples here and curl to write a script as well.