ENAPSO Graph Databases Command Line Interface (CLI) for Node.js
ENAPSO Command Line Interface to easily perform numerous operations on the graph databases. This tool will be continuously extended by further scriptable convenience operations.
As of now, we support the connection with three major graph databases
There will be more graph databases added to this list in the future.
You may also find these tools useful
- ENAPSO Graph Database Client: To perform SPARQL queries and update statements against your knowledge graphs or ontologies stored in your graph database.
- ENAPSO Graph Database Admin: To perform administrative and monitoring operations against your graph databases, such as importing and exporting ontologies/knowledge graphs and utilizing the graph database's special features.
npm i -g @innotrade/enapso-graphdb-cli
Command | Description | Ontotext GraphDB | Apache Jena Fuseki | Stardog |
---|---|---|---|---|
export | Exports (download) the triples from a specific context or a repository of graph database to the local file. | ✔ | ✔ | ✔ |
import | Imports (upload) ontology in a specific context or default graph of graph database repository. | ✔ | ✔ | ✔ |
clearRepository | Remove all triples from the repository of graph database. | ✔ | ✔ | ✔ |
createRepository | Create a new repository in the graph database. | ✔ | ✔ | ✔ |
deleteRepository | Delete the repository from graph database. | ✔ | ✔ | ✔ |
createUser | Create a new user and assign roles in the graph database. | ✔ | ✘ | ✔ |
updateUser | Update the existing user roles in graph database. | ✔ | ✘ | ✘ |
assignRoles | Assign new roles to the existing user of the graph database. | ✘ | ✘ | ✔ |
removeRoles | Remove existing roles of the user in graph database. | ✘ | ✘ | ✔ |
deleteUser | Delete the user of the graph database. | ✔ | ✘ | ✔ |
garbageCollection | Perform garbage collection in the repository of graph database. | ✔ | ✘ | ✘ |
getResources | Get resources used by the repository of graph database. | ✔ | ✘ | ✘ |
query | Perform read query against ontology imported in the repository of a graph database. | ✔ | ✔ | ✔ |
update | Perform update query against ontology imported in the repository of graph database. | ✔ | ✔ | ✔ |
importServerFile | Import the file which are available on the graphdb server. | ✔ | ✔ | ✔ |
Parameter | Abbreviation | Parameter Description |
---|---|---|
dburl | d | Base url in which graph database is running. |
repository | r | Name of the repository of the graph database with which you want to create a connection |
version | Version of the graph database, by default works with the latest version. | |
apiType | Api type of graph database (workbench or RDF4J) to use for import by default it used workbench API. | |
context | c | To pass the context |
username | u | To pass the name of the user against you want to authenticate yourself in a graph database. |
user | To pass the name of the user which you want to delete or update in the graph database. | |
password | p | Password to be used for authentication in the graph database. |
baseiri | i | Base iri of the graph e.g. http://ont.enapso.com/ . |
targetfile | t | File path for exports to file |
sourcefile | s | File path of import from file. |
queryfile | q | File path of the query file (SPARQL). |
format | f | Specify format of the ontology file. |
authorities | f | Pass the user roles of the graph database |
Download a repository or a specific named graph from graph database to a file:
enapsogdb export --dburl "http://localhost:7200" --repository "Test" --context "http://ont.enapso.com/test" --targetfile "exports/export.ttl" --username "admin" --password "root" --format "text/turtle"
Upload from a file to the repository of graph database:
enapsogdb import --dburl "http://localhost:7200" --repository "Test" --context "http://ont.enapso.com/test" --baseiri "http://ont.enapso.com/test#" --sourcefile "imports/dotnetpro_demo_ontology_2.owl" --username "admin" --password "root" --format "application/rdf+xml"
Upload from a file to the repository of graph database using RDF4J API:
enapsogdb import --dburl "http://localhost:7200" --apiType "RDF4J" --repository "Test" --context "http://ont.enapso.com/test" --baseiri "http://ont.enapso.com/test#" --sourcefile "imports/dotnetpro_demo_ontology_2.owl" --username "admin" --password "root" --format "application/rdf+xml"
Import file which are available on the server
enapsogdb importServerFile --dburl "http://localhost:7200" --repository "Test" --context "http://ont.enapso.com/test" --baseiri "http://ont.enapso.com/test#" --filename "dotnetpro_demo_ontology_2.owl" --username "admin" --password "root"
Clear the entire repository. Caution! Use this command with care! The operation cannot be undone!
enapsogdb clearRepository --dburl "http://localhost:7200" --repository "Test" --username "admin" --password "root"
Clear specific named graphs from a graph database repository. Caution! Use this command with care! The operation cannot be undone!
enapsogdb clearContext --dburl "http://localhost:7200" --repository "Test" --context "http://ont.enapso.com/test" --username "admin" --password "root"
Perform the garbage collection of the Graph Database.
enapsogdb gc --dburl "http://localhost:7200" --username "admin" --password "root"
Get resources of the Graph Database.
enapsogdb gc --dburl "http://localhost:7200" --username "admin" --password "root"
Create New Repository in the Graph Database.
enapsogdb createRepository --dburl "http://localhost:7200" --repository "TestRepository" --repotitle "Test Repository" --username "admin" --password "root"
Delete Repository of Graph Database.
enapsogdb deleteRepository --dburl "http://localhost:7200" --repository "TestRepository" --username "admin" --password "root"
Create a new user in the Graph Database.
enapsogdb createUser --dburl "http://localhost:7200" --repository "Test" --username "admin" --password "root" --newusername "TestUser" --newpassword "TestUser" -a "ROLE_USER WRITE_REPO_Test READ_REPO_Test READ_REPO_EnapsoDotNetProDemo"
Update existing users of the Graph Database.
enapsogdb updateUser --dburl "http://localhost:7200" --repository "Test" --username "admin" --password "root" --user "TestUser" --newpassword "TestUser" -a "ROLE_USER WRITE_REPO_Test READ_REPO_Test WRITE_REPO_EnapsoDotNetProDemo READ_REPO_EnapsoDotNetProDemo"
Assign a role to an existing user of the Graph Database.
enapsogdb assignRoles --dburl "http://localhost:5820" --repository "Test" --username "admin" --password "admin" --user "TestUser" --newpassword "TestUser" -a '[{"action":"READ","resource_type":"db","resource":["Test"]},{"action":"WRITE","resource_type":"db","resource":["Test"]}]' --triplestore "stardog"
Remove roles of the existing user of graph database.
enapsogdb removeRoles --dburl "http://localhost:5820" --repository "Test" --username "admin" --password "admin" --user "TestUser" --newpassword "TestUser" -a '[{"action":"READ","resource_type":"db","resource":["Test"]},{"action":"WRITE","resource_type":"db","resource":["Test"]}]' --triplestore "stardog"
Delete existing users of the graph database.
enapsogdb deleteUser --dburl "http://localhost:7200" --repository "Test" --username "admin" --password "root" --user "TestUser"
Read the data from graph database
enapsogdb query --dburl "http://localhost:7200" --repository "Test" --username "admin" --password "root" --queryfile "queries/all.sparql" --prefixfile "queries/prefixes.prf" --targetfile "results/countries.csv"
Update the data of the graph database
enapsogdb update --dburl "http://localhost:7200" --repository "Test" --username "admin" --password "root" --queryfile "queries/createClass.sparql" --prefixfile "queries/prefixes.prf"
enapso-graphdb-cli project contain the shell script, which check the memory used by graph database if it is more than 4 GB then it perform the garbage collection.
- Install and run GraphDB 10.x (https://graphdb.ontotext.com/)
- Set the following variables in shell script file (
../shell-script/auto-perform-garbage-collection.sh
)repo
name of the repository of Graph database by default, it's value is "Test".baseURL
URL on which graph database is running by default, it' value is "http://localhost:7200".user
name of the user of the graph database by default, it' value is "admin".password
password of the user of the graph database by default, it' value is "root".reprtFile
path of result output by default, it's value is "../Report/resource-report.txt".
To run the shell script available at ../shell-scripts/auto-perform-garbage-collection.sh
access permission needs to be granted to the shell script and enapso-graphdb-cli executable (../enapso-graphdb-cli-exe/
) which is corresponding to your operating system to run it successfully.
The following file types are supported:
name: "JSON",
type: "application/rdf+json",
extension: ".json"
name: "JSON-LD",
type: "application/ld+json",
extension: ".jsonld"
name: "RDF-XML",
type: "application/rdf+xml",
extension: ".rdf"
name: "N3",
type: "text/rdf+n3",
extension: ".n3"
name: "N-Triples",
type: "text/plain",
extension: ".nt"
name: "N-Quads",
type: "text/x-nquads",
extension: ".nq"
name: "Turtle",
type: "text/turtle",
extension: ".ttl"
name: "TriX",
type: "application/trix",
extension: ".trix"
name: "TriG",
type: "application/x-trig",
extension: ".trig"
name: "Binary RDF",
type: "application/x-binary-rdf",
extension: ".brf"
Tutorial to run the Test suite against the graph database.
Contributing is more than just coding. You can help the project in many ways, and we will be very happy to accept your contribution to our project.
Details of how you can help the project are described in the CONTRIBUTING.md document.
Do you have a bug report or a feature request?
Please feel free to add a new issue or write to us in discussion: Any questions and suggestions are welcome.
This project is licensed under the Apache 2.0 License. See the LICENSE file for more details.