Development

Weaviate Database CLI Tool

n this tutorial, we will walk you through installing and using the Weaviate CLI on your machine.
Captain Salem 2 min read
Weaviate Database CLI Tool

Weaviate is a free and open-source, cloud-native, and decentralized knowledge graph system designed to store and retrieve complex data in a highly scalable and efficient manner. Weaviate is built to handle vectorized data, allowing it to perform advanced semantic searches and other machine-learning tasks.

One way of interacting with the Weaviate cluster is using the Weaviate CLI tool. This command-line tool provides a simple interface for interacting and performing administrative tasks, managing data, and cluster configuration.

Requirements

To follow along with this tutorial, ensure you have the following:

  1. A running Weaviate cluster
  2. Python 3.10 and above.

Installing the Weaviate CLI

The first step is to install the Weaviate CLI on your machine. Luckily, the Weaviate CLI is available as a Python package which means we can install it using pip as shown in the command below:

$ pip3 install weaviate-cli

Once installed, you may need to perform basic configuration. You can do this by running the command:

$ weaviate init

This should prompt you to provide details to your Weaviate cluster, such as the authentication methods and API keys.

Once configured, verify that everything is working correctly by running the command:

$ weaviate version

The command should return the installed weaviate version.

Weaviate View Configuration.

One of the major use of the Weaviate CLI is performing configuration. The first command will look at allows you to view the configuration for your Weaviate CLI.

Use the command as shown:

$ weaviate config view

You should get the configuration details including the authentication details. An example output is as shown:

{
"url": "https://linuxhint-yls99k5n.weaviate.network",
"auth": null
}

Weaviate Ping

The second command lets you ping the Weaviate server configured in the Weaviate CLI. You can use the ping command to ensure that the server is running:

$ weaviate ping

The command should print a status message showing whether the server is reachable.

Weaviate is reachable!

Weaviate CLI Version

To check the installed version of the Weaviate CLI, you can use the command:

$ weaviate version

Output:

2.3.0

Weaviate Schema Import, Export, and Delete

Another set of commands from the Weaviate CLI allows you to import, export, or delete a Weaviate schema.

Weaviate CLI add schema.

$ weaviate schema import my_schema.json

Export an existing Weaviate schema with the command:

$ weaviate schema export my_schema.json

To delete a schema and all the data associated with it, you can use the delete command:

$ weaviate schema delete

Weaviate CLI Data Import and Delete

We also import or delete data using the Weaviate CLI, as shown. To import data from a JSON file, use the command:

$ weaviate data import my_data_objects.json

To delete all the data objects in Weaviate, we can use the command:

$ weaviate data delete

This should wipe all the data in the cluster.

Conclusion

In this tutorial, we covered the basics of installing, configuring, and using the various commands provided by the Weaviate CLI.

Share
Comments
More from Cloudenv

Cloudenv

Developer Tips, Tricks and Tutorials.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Cloudenv.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.