Datastore¶
Datastores are fully integrated repositories to manage and persist data. They can record data calculated by Everysk’s servers, proprietary data from the client or both. The most common usage is the storage of securities as rows and related properties as columns, but there are no constraints on the usage. They enable powerful data explorations and trend analysis to be performed.
The Datastore entity is kept under the following import statement:
Below we have the most common attributes used in the Datastore entity:
-
name: The name of the Datastore entity. -
tags: The tags of the datastore. -
description: The current description of the datastore. -
workspace: Which workspace will the Datastore entity reside. -
date: The date of the datastore. -
data: The data associated with the current datastore. -
level: The level of the datastore.
Instantiating a Datastore Entity and Passing Attributes¶
To instantiate a Datastore entity, we can use the following code snippet:
Now we can manually set the class attributes in order to properly configure our Datastore entity.
datastore.name = 'SampleDatastore'
datastore.tags = ['tag1', 'tag2']
datastore.description = 'Description'
datastore.workspace = 'SampleWorkspace'
datastore.date = DateTime(2023, 9, 9, 9, 9, 9, 9)
datastore.data = 'data'
datastore.level = 1
Convert Datastore to a Dictionary¶
Most times when working with entities, there might be a point where we need to convert the entity to a dictionary, and to achieve this we simply use the to_dict() method:
datastore = Datastore()
type(datastore)
everysk.sdk.entities.datastore.base.Datastore
to_dict = datastore.to_dict()
type(to_dict)
# dict
Validating a Datastore Entity¶
The validate() method from the Datastore entity is used as a lazy validation method in order to check if the entity is valid or not by returning a boolean value:
In the case of an invalid entity, meaning that some field is missing or has an invalid value, the validate() method will raise a FieldValueError:
datastore = Datastore()
datastore.id = 'invalid_id'
# FieldValueError: The value 'invalid_id' for field 'id' must match with this regex: ^dats_[a-zA-Z0-9].