Use the AnzoGraph DB CLI
You can use the AZGI command line interface to run commands and access data in AnzoGraph DB. AZGI uses SSL protocol to interact with the database. The client exists in the <install_path>/bin
directory. In a container deployment, the installation path is /opt/anzograph
. On RHEL/Rocky deployments, the installation path is customizable. The default path is /opt/cambridgesemantics/anzograph
. In a cluster, use azgi on the leader node only.
AnzoGraph DB also includes an alternate command line interface (AZGBOLT), which uses the Bolt protocol and enables you to run Cypher queries. For information, see Using the Cypher CLI (AZGBOLT).
AZGI Syntax
This section describes the available azgi command options. To view the list of options from the command line, run azgi -help
.
azgi [-f <filename>] [-c "<command>"] [-set <param>=<value>] [-h <host_url>] [-p <port>] [-u <username>:<password>] [-v] [-timer] [-raw] [-csv] [-json] [-xml] [-silent] [-nohead] [-noprogress] [-maxwid <width>] [-wide] [-nossl] [-o <file>] [-certs <directory>] [-context <json_file>]
-f <filename>
Runs the specified SPARQL query file. For example, the following command runs the query or queries in the query.rq file:
azgi -f /home/user/query.rq
-c "<command>"
Runs the command in quotation marks. For example, this command runs a query:
azgi -c "select distinct ?eventname from <http://anzograph.com/tickit> where {?event <http://anzograph.com/tickit/eventname> ?eventname} limit 100"
You can include multiple -c options to run multiple commands. For example, this command runs two queries:
azgi -c "select * from <http://anzograph.com/tickit> where {?s ?p ?o}" -c "select distinct ?likes from <http://anzograph.com/tickit> where {?person <http://anzograph.com/like> ?likes}"
And this command sets the query_label setting to "events" before running the query:
azgi -c "set query_label to 'events'" -c "select distinct ?event from <http://anzograph.com/tickit> where {?event <http://anzograph.com/eventname> ?event} limit 100"
-set <param>=<value>
Sets or changes parameter values in query files. For example this command runs the query in the query_summary.rq file with the $query parameter set to 2:
azgi -set query=2 -f query_summary.rq
-h <host_url>
Connects to a remote AnzoGraph DB server. For example, the following statement runs a query against AnzoGraph DB on host 10.104.55.27:
azgi -h 10.104.55.27 -c "select * from <http://anzograph.com/tickit> where {?s ?p ?o} limit 100"
-p <port>
Used to connect to the database on a non-default port. The default azgi port is 8256.
-u <username>:<password>
Connects to the database with credentials (basic authentication). If you type -u <username> and exclude the password, the client prompts for the password. For example, the following command uses basic authentication to run a query:
azgi -u admin:Passw0rd1 -c "select ?g where {graph ?g {?s ?p ?o}} limit 10"
-v
Displays verbose output such as client connection details. For example:
azgi -v -c "select distinct ?p from <http://anzograph.com/tickit> where {<http://anzograph.com/tickit/person1> ?p ?o}"
Connecting to host=localhost port=8256 IPv4: connected POST /sparql HTTP/1.1 Host: Anon Accept: application/sparql-results+xml User-Agent: azgi Connection: keep-alive Content-Length: 106 Content-Type: application/sparql-query select distinct ?p from ... HTTP/1.1 200 OK Date: Fri, 14 Apr 2023 21:37:16 GMT Server: AnzoGraph Access-Control-Allow-Origin: * X-AnzoGraph-QueryExecution-Time: 2837 Connection: close Content-Type: application/sparql-results+xml; charset=utf-8 ...
-timer
Reports query execution time in milliseconds.
-raw
Returns query results in raw XML, JSON, or CSV format, depending on what format you request.
-csv
Returns results in CSV format.
-json
Returns results in JSON format.
-xml
Returns results in XML format.
-silent
Suppresses the query output.
-nohead
Suppresses headings in query results.
-noprogress
Suppresses the progress messages that are displayed for queries that are inflight.
-maxwid <width>
Overrides the default maximum column width of 50 characters for tabular query results. Using the -wide option described below is equivalent to maxwid 60000
.
-wide
Increases the column width for tabular query results from the default 50 characters to 60,000 characters. Equivalent to -maxwid 60000
.
-nossl
Instructs the client to make a non-SSL (HTTP) connection to the database. When using AZGI to send a request to a remote AnzoGraph DB server, include the -h <host_url>
and -p <port>
options when using -nossl
. The default HTTP port is 7070. For example:
azgi -nossl -h 10.100.0.20 -p 7070 -c "select (count(*) as ?cnt) where {?s ?p ?o}"
-o <file>
Writes the response to the specified file. If the file exists, it is overwritten.
When you include this option to redirect output to a file, all progress messages will also be written to the file unless you also specify the -noprogress option. Cambridge Semantics recommends that you include -noprogress
any time you output results to a file.
-certs <directory>
Instructs the client to make a certified secure connection to the database. The AnzoGraph DB certificates are ca.crt, serv.crt (public key), and serv.key (private key) in the <install_path>/config
directory. When sending requests to a remote AnzoGraph DB server, you can copy the certificates to the server where you are using AZGI. For example, the following command runs a query on a remote AnzoGraph DB server. The command makes a certified connection using the AnzoGraph DB certificates, which were copied to the /home/user/certs
directory:
azgi -h 10.10.10.01 -certs /home/user/certs -c "select ?g where {graph ?g {?s ?p ?o}} limit 100"
This command runs the same query from the AnzoGraph DB server.
azgi -certs /opt/cambridgesemantics/anzograph/config -c "select ?g where {graph ?g {?s ?p ?o}} limit 100"
-context <json_file>
Specifies the query context file on the AnzoGraph DB server file system to use with the request. Context files are JSON-formatted files with key-value pairs that provide connection details, such as user credentials, keys, and tokens, for authentication against data sources. For more information, see Use a Query Context.