Using the AnzoGraph Command Line Interface
You can use the AnzoGraph AZGI command line interface (CLI) in the /AnzoGraph_root_dir/bin
directory to issue commands directly to the AnzoGraph database.
Important: The AZGI CLI works on the SPARQL HTTP port and is enabled only when HTTP access is enabled. HTTP access is controlled by the enable_sparql_protocol setting. If you disabled HTTP access and want to enable it so that you can use the command line, see Changing AnzoGraph Configuration Settings for instructions.
This section describes the available AZGI commands. To view the list of AZGI options from the command line, run azgi -help.
AZGI Usage
azgi [-f filename] [-c "command"] [-raw] [-csv] [-silent] [-v] [-h host_url]
[-p port] [-timer] [-max_colwid width] [ -wide ] [-nohead]
Option | Description |
---|---|
-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 <tickit>
where {?event <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 <tickit> where {?s ?p ?o} limit 100" -c "select distinct ?likes
from <tickit> where {?person <like> ?likes}" And this command sets the output format to JSON before running the query: azgi -raw -c "set output_format to 'json'" -c "select distinct ?eventname
from <tickit> where {?event <eventname> ?eventname} limit 100" |
-raw | Displays query results in raw XML, JSON, or CSV format, depending on what the format you request. You must specify this option if you request JSON or CSV. You must also use the raw option when running CONSTRUCT queries. For example:azgi -raw -c "construct {<person00> ?p ?o} from <tickit> where {<person1> ?p ?o}" |
-csv | Displays query results in CSV format. When you use this option on the command line, you do not need to specify -raw. For example:
azgi -csv -c "select * from <tickit> where {<person1> ?p ?o}" |
-silent | Suppresses the query output. |
-v | Displays verbose output such as client connection details. For example:azgi -v -c "select distinct ?p from <tickit> where {<person1> ?p ?o}" do_connect: connecting to host=localhost POST /sparql/ HTTP/1.1 Host: Anon Accept: text/html, application/sparql-results+xml, text/csv, application/xhtml+xml, application/xml, application/sparql, application/turtle; q=0.9,*/*;q=0.8 User-Agent: isbx Connection: keep-alive Content-Length: 57 Content-Type: application/sparql-query select distinct ?p from <tickit> where {<person1> ?p ?o} HTTP/1.1 200 OK Date: Wed, 10 Jan 2018 20:25:47 GMT Server: SPARQLverse Access-Control-Allow-Origin: * Connection: close Content-Type: application/sparql-results+xml; charset=utf-8 <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="p"/> </head> <results> ... |
-h host_url | Connects to a remote AnzoGraph server. For example, the following statement runs a query against AnzoGraph installed on host 10.104.55.27:azgi -h 10.104.55.27 -c "select * from <tickit> where {?s ?p ?o} limit 100" |
-p port | Used to connect to AnzoGraph on a non-default port or when using the azgi CLI from a remote server. |
-timer | Reports query execution time in milliseconds. |
-max_colwid width | Overrides the default maximum column width of 50 characters for tabular query results. For example, for a data set with long graph names, you can expand column width to view the entire name:
azgi -max_colwid 10000 -c "select ?g where {graph ?g {?s ?p ?o}} limit 100" Note: Using the -wide option described below is equivalent to "max_colwid 60000." |
-wide | Increases the column width for tabular query results from the default 50 characters to 60,000 characters. Equivalent to "max_colwid 60000." |
-nohead | Suppresses headings in query results. |