Data Collections

The Hyperspace database stores data under Collections, which are distinct segments within the database. Before using the following commands, you must establish a local Hyperspace instance in order to allocate the essential resources and functions.

  • Creating a Collection

  • Committing a Collection

  • Deleting a Collection

  • Clearing a Collection

  • Getting a Collection Scheme

Creating a Collection

The following command creates a Collection.

hyperspace_client.create_collection('schema.json', collection_name')

Where

  • schema.json – Specifies the path to the configuration file (for example, \schema.json) that you created locally on your machine, as described in Creating a Database Schema Configuration File.

  • collection_name – Specifies the name of the Collection to be created in the Hyperspace database. You can specify any name as long as it is unique to your Hyperspace Collection.

Response

The following response should be received –

{'status': 'OK', 'code': 200, 'message': 'Collection was successfully created'}

Committing a Collection

After you upload the data, it is required that you commit it, by running the following command to initiate the process of Hyperspace automatically backing up uploaded data periodically. Hyperspace handles data restoration automatically and transparently.

The following command creates a Collection.

hyperspace_client.commit(collection_name)

Where

  • collection_name – Specifies the name of the Collection to be committed to the Hyperspace database.

Deleting a Collection

The following command describes how to delete a Collection.

hyperspace_client.delete_collection(collection_name)

Where

  • collection_name – Specifies the name of the Collection to be deleted from the Hyperspace database.

You may want to do this in order to save storage space or clean up your space, but please note that this is an irreversible operation.

Clearing a Collection

The following describes how to clear a Collection, which erases all the data in the Collection.

hyperspace_client.clear_collection(collection_name)

Getting a Collection Scheme

The following describes how to get a Collection's schema.

schema = hyperspace_client.get_schema(collection_name)

Last updated