n1ql2csv
Executes a given N1QL query and exports the results as CSV
Install
Install n1ql2csv
globally
npm install n1ql2csv -g
Requires Node, if you don't have node, you can install nvm
by issuing the following command.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
then
nvm install 9
Usage
n1ql2csv --help Usage: n1ql2csv [options] This will execute a N1QL query and export the results into a csv file Options: -V, --version output the version number -c, --cluster <s> The cluster address -s, --secure <b> Whether or not to use http -p, --port <n> The query port to use -u, --username <s> Cluster Admin or RBAC username -p, --password <s> Cluster Admin or RBAC password -s, --statement <s> A N1QL statement or file path to a N1QL query -o, --output <s> The destination output file -x, --overwrite <b> Overwrite the destination file
Example
n1ql2csv \ --cluster localhost \ --username Administrator \ --password password \ --statement "SELECT airportname, city, country, faa, icao, id, type, tz FROM \`travel-sample\` AS airports WHERE type ='airport' ORDER BY airportname ASC" \ --output somedir/results.csv \ --overwrite true