Using the AnzoGraph CLI
You can use the azgi command line interface (CLI) in the <install_path>/bin
directory to issue commands directly to the database.
The azgi CLI works on the SPARQL HTTPS port and is enabled only when SSL protocol is enabled. SSL access is controlled by the enable_ssl_protocol setting. If HTTPS access is disabled and you want to enable it so that you can use the CLI, see Changing AnzoGraph Server Settings for instructions.
This section describes the available azgi commands. To view the help, run azgi -help
.
AZGI Usage
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://cambridgesemantics.com/tickit> where {?event <http://cambridgesemantics.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://cambridgesemantics.com/tickit> where {?s ?p ?o} limit 100" -c "select distinct ?likes from <http://cambridgesemantics.com/tickit> where {?person <http://cambridgesemantics.com/like> ?likes}"
And this command sets the query_label configuration setting to "events" before running the query:
azgi -c "set query_label to 'events'" -c "select distinct ?eventname from <http://cambridgesemantics.com/tickit> where {?event <http://cambridgesemantics.com/eventname> ?eventname} 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 server. For example, the following statement runs a query against AnzoGraph on host 10.104.55.27:
azgi -h 10.104.55.27 -c "select * from <http://cambridgesemantics.com/tickit> where {?s ?p ?o} limit 100"
-p <port>
Used to connect to AnzoGraph 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 100"
-v
Displays verbose output such as client connection details. For example:
azgi -v -c "select distinct ?p from <http://cambridgesemantics.com/tickit> where {<http://cambridgesemantics.com/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: 38 Content-Type: application/sparql-query select distinct ?p from <http://cambridgesemantics.com/tickit> where {<http://cambridgesemantics.com/person1> ?p ?o} HTTP/1.1 200 OK Date: Tue, 30 Jun 2020 00:24:42 GMT Server: AnzoGraph Access-Control-Allow-Origin: * X-AnzoGraph-QueryExecution-Time: 20 Connection: close Content-Type: application/sparql-results+xml; charset=utf-8 ...
-timer
Reports query execution time in milliseconds.
-raw
Displays query results in raw XML, JSON, or CSV format, depending on what format you request.
-csv
Displays results in CSV format.
-json
Displays results in JSON format.
-xml
Displays 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 in flight.
-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 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 specify 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 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 server, you can copy the AnzoGraph certificates to the server where you are using AZGI. For example, the following command runs a query on a remote AnzoGraph server. The command makes a certified connection using the AnzoGraph 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 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 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 example:
{ "url": "jdbc:mysql://10.111.4.9:3306/NORTHWIND", "username": "sysadmin", "password": "admin123" }