Using the AnzoGraph Command Line Interface
You can use the azgi command line interface (CLI) in the /install_path/bin
directory to issue commands directly to the 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 options from the command line, run azgi -help
.
AZGI Usage
azgi [-f filename] [-c "command"] [-csv] [-json] [-xml] [-h hostname] [-p port] [-timer] [-silent] [-max_colwid width] [-wide] [-set parameter=value] [-v]
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}" |
-csv | Returns results in CSV format. For example:
azgi -csv -c "select * from <tickit> where {<person1> ?p ?o} limit 5" p,o http://www.w3.org/1999/02/22-rdf-syntax-ns#type,person like,classical like,musicals like,sports like,theatre |
-json | Returns results in JSON format. For example:azgi -json -c "select distinct ?name from <tickit> where {?event <eventname> ?name} limit 3" {"head":{"vars":["name"]},"results":{"bindings":[{"name":{ "datatype":"http://www.w3.org/2001/XMLSchema#string","type":"typed-literal", "value":"La Rondine"}},{"name":{"datatype":"http://www.w3.org/2001/XMLSchema#string", "type":"typed-literal","value":"Il Trovatore"}},{"name":{ "datatype":"http://www.w3.org/2001/XMLSchema#string", "type":"typed-literal","value":"Ring Cycle"}}]}} |
-xml | Returns results in XML format. |
-h hostname | 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. |
-silent | Suppresses the query output. |
-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." |
-set parameter=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 |
-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 port=7070 POST /sparql HTTP/1.1 Host: Anon Accept: application/xml, text/html User-Agent: azgi Connection: keep-alive Content-Length: 26 Content-Type: application/sparql-query ... |