Reputation: 1073
I am very new to arango DB nosql I try to get the exported output of arangoDB with shell commands or arangosh commands but I could not find any way. I know serialization to application can definitely help. However, I am looking for cli methods to get it done.
There is a way to use pyarango where we can ostream the results to file. However looking for solution like
echo " db._query('return (length(table_name))')"|arangosh --server.database "qadb" --server.endpoint "tcp://127.0.0.1:8529" --server.username "qatest" --server.password "TTT"
However, In my case I could get the results and command ended to open the arangosh shell. Please help to make understanding.
Upvotes: 1
Views: 511
Reputation: 6067
ArangoDB offers several ways of scripting. You can use curl as documented with the HTTP-API
curl --dump - http://localhost:8529/_api/version?details=true
The HTTP-API is what all drivers are based on. So if its possible to achieve via arangosh, you can do it with curl (maybe with the aid of jq to extract the required information)
You can also use arangosh to execute arbitrary commands passed in (as pointed out by CoDEmanX:
arangosh --server.database qadb \
--server.username qatest \
--server.password TTTT \
--javascript.execute-string \
"print(db._query('RETURN LENGTH(collection_name)'))"
You can also use arangosh
to run scripts using the standard unix shebang mechanism:
#!/usr/bin/arangosh --javascript-execute
print(db._query('RETURN LENGTH(collection_name)'));
Save the above to i.e. /tmp/test.js
and make it executable with chmod a+x /tmp/test.js
, you then can simply invoke it:
/tmp/test.js
SOME_BASH_VAR=`/tmp/test.js`
echo "${SOME_BASH_VAR}"
/tmp/test.js > /tmp/output_of_arangosh.json
To generally export collections you should use arangodump.
Upvotes: 2