Datastores#

Datastores connect Agents and Flows to data modelled by entity definitions. To see how you can use a datastore in a Flow or Agent, see Datastore task steps.

Entity#

Entities define the data model of datastores.

class wayflowcore.datastore.Entity(name='', description='', default_value=<class 'wayflowcore.property._empty_default'>, enum=None, _validate_default_type=False, __metadata_info__=<factory>, properties=<factory>)#

An Entity defines the properties of an object in a collection manipulated by a datastore.

Entities can be used to model relational entities, where their properties are the columns of the tables, as well as any other kind of entity. For example, a text file on OCI Object Storage can be represented as an entity with properties file name and content.

Parameters:
  • name (str) –

    Optional name of the entities described by this object.

    Note

    In a datastore, the relevant name is the one provided as the dictionary key of the schema parameter for the corresponding Entity.

  • description (str) –

    Optional description of the entity type.

    Important

    It can be helpful to put a description in the following cases:

    • to help users know what this entity is about, and simplify the usage of a Step using it

    • to help a LLM if it needs to generate values for this entity (e.g. in DatastoreCreateStep)

    • to help an agent when tools are generated from the Datastore operations, to automatically provide a comprehensive docstring for that tool

  • default_value (Any) – Optional default value.

  • properties (Dict[str, Property]) –

    Mapping of property names and their types. Defaults to no properties.

    Important

    If a property is not required (but doesn’t have a default value conforming to its type), use the nullable helper function to create a new property that can be set to None.

  • enum (Tuple[Any, ...] | None)

  • _validate_default_type (bool)

  • __metadata_info__ (Dict[str, Any])

Examples

>>> from wayflowcore.datastore import Entity, nullable
>>> from wayflowcore.property import StringProperty, IntegerProperty

You can define an entity representing documents with metadata as follows:

>>> documents = Entity(
...     description="Documents in object store, including category metadata",
...     properties={
...         "id": IntegerProperty(),
...         # By default, documents are created empty
...         "content": StringProperty(default_value=""),
...         # Category is empty by default
...         "category": nullable(StringProperty()),
...     }
... )
get_entity_defaults()#

Construct a dictionary of default values for properties that have them.

This method can be helpful to supplement default values in an entity object. Note that datastores already provide this functionality on creation of an object.

Returns:

A dictionary mapping each property name in the dictionary to its default value (if it has one, otherwise it will not be part of this dictionary)

Return type:

dict[str, Any]

class wayflowcore.datastore.nullable(property)#

Makes a property nullable.

Parameters:

property (Property) – Property that can be null. If a default value is set on this property the resulting nullable property will have the same default value. If no default value is set, the default of the resulting property is None.

Returns:

A new property descriptor that is equivalent to the original one, but that can also be None.

Return type:

UnionProperty

Base class#

class wayflowcore.datastore.Datastore(schema, search_configs=None, vector_configs=None, id=None, name=None, description=None, __metadata_info__=None)#

Store and perform basic manipulations on collections of entities of various types.

Provides an interface for listing, creating, deleting and updating collections. It also provides a way of describing the entities in this datastore.

Initialize a Datastore.

Parameters:
  • schema (dict[str, Entity]) – Mapping of collection names to entity definitions used by this datastore.

  • search_configs (Optional[List[SearchConfig]]) – List of search configurations for vector search capabilities. By default, it’s set as None. If no search config is given, the datastore will not support Search functionality.

  • vector_configs (Optional[List[VectorConfig]]) – List of vector configurations for vector generation and storage. By default, it’s set as None. If None, a vector config will be inferred for each vector property found in the schema.

  • id (Optional[str]) – Optional unique identifier for this datastore instance. Default is None.

  • name (Optional[str]) – Optional name to help identify this datastore. Default is None.

  • description (Optional[str]) – Optional human-readable description of the datastore. Default is None.

  • __metadata_info__ (Dict[str, Any] | None)

abstract create(collection_name, entities)#

Create new entities of the specified type.

Parameters:
  • collection_name (str) – Name of the collection to create the new entities in.

  • entities (Union[Dict[str, Any], List[Dict[str, Any]]]) –

    One or more entities to create. Creating multiple entities at once may be beneficial for performance compared to executing multiple calls to create.

    Important

    When bulk-creating entities, all entities must contain the same set of properties. For example, if the Entity “employees” has properties “name” (required) and “salary” (optional), either all entities to create define only the name, or all define both name and salary. Some entities defining the salary and others relying on its default value is not supported.)

Returns:

The newly created entities, including any defaults not provided in the original entity. If the input entities were multiples, they will be returned as a list. Otherwise, a single dictionary with the newly created entity will be returned.

Return type:

list[dict] or dict

abstract delete(collection_name, where)#

Delete entities based on the specified criteria.

Parameters:
  • collection_name (str) – Name of the collection in which entities will be deleted.

  • where (Dict[str, Any]) – Filter criteria for the entities to delete. The dictionary is composed of property name and value pairs to filter by with exact matches. Only entities matching all conditions in the dictionary will be deleted. For example, {"name": "Fido", "breed": "Golden Retriever"} will match all Golden Retriever dogs named Fido.

Return type:

None

abstract describe()#

Get the descriptions of the schema associated with this Datastore.

Returns:

The description of the schema for the Datastore.

Return type:

dict[str, Entity]

get_search_toolbox(collection_names=None, search_configs=None, k=3, requires_confirmation=None)#

Get search toolbox for entities to pass into an Agent.

Parameters:
  • collection_names (Optional[List[str]]) – Which collection names to expose tools for; None => all.

  • search_configs (Optional[List[str]]) – Names of the search_configs to expose. If set to None, all search_configs are exposed as tools.

  • k (int) – Number of results to return for search tools (will be fixed, not changeable by Agent). It is only configurable by the user as k heavily impacts speed and cost: searching for more leads to more being put in the context of the next LLM call.

  • requires_confirmation (Optional[bool]) – Flag to ask for user confirmation whenever executing any of this toolbox’s tools, yields ToolExecutionConfirmationStatus if True or if the Tool from the ToolBox requires confirmation.

Returns:

A toolbox containing search tools for the specified collections.

Return type:

ToolBox

get_search_tools(collection_names=None, search_configs=None, k=3, requires_confirmation=None)#

Get search tools for entities to pass into an Agent.

Parameters:
  • collection_names (Optional[List[str]]) – Which collection names to expose tools for; None => all.

  • k (int) – Number of results to return for search tools (will be fixed, not changeable by Agent). It is only configurable by the user as k heavily impacts speed and cost: searching for more leads to more being put in the context of the next LLM call.

  • requires_confirmation (Optional[bool]) – Flag to ask for user confirmation whenever executing any of this toolbox’s tools, yields ToolExecutionConfirmationStatus if True or if the Tool from the ToolBox requires confirmation.

  • search_configs (List[str] | None)

Returns:

A list containing search tools for the specified collections.

Return type:

List[Tool]

abstract list(collection_name, where=None, limit=None)#

Retrieve a list of entities in a collection based on the given criteria.

Parameters:
  • collection_name (str) – Name of the collection to list.

  • where (Optional[Dict[str, Any]]) – Filter criteria for the collection to list. The dictionary is composed of property name and value pairs to filter by with exact matches. Only entities matching all conditions in the dictionary will be listed. For example, {"name": "Fido", "breed": "Golden Retriever"} will match all Golden Retriever dogs named Fido.

  • limit (Optional[int]) – Maximum number of entities to retrieve, by default None (retrieve all entities).

Returns:

A list of entities matching the specified criteria.

Return type:

list[dict]

search(*args, **kwargs)#

Search for entities matching a query in an synchronous manner. See the search_async method to get details about the parameters.

Note: While performing search, at least one of search_config or collection_name must be specified.

Return type:

List[Dict[str, Any]]

Parameters:
  • args (Any)

  • kwargs (Any)

async search_async(query, collection_name=None, search_config=None, k=3, where=None, columns_to_exclude=None)#

Search for entities matching a query in an asynchronous manner.

Note: While performing search, at least one of search_config or collection_name must be specified.

Parameters:
  • query (str) – Search query string to find matching entities.

  • collection_name (Optional[str]) – Optional name of the collection to search within.

  • search_config (Optional[str]) – Optional search configuration name to use; if None, infers config from collection name.

  • k (int) – Number of results to return (default: 3).

  • where (Optional[Dict[str, Any]]) – Optional filters to apply to search results. The dictionary keys are column names, and the values are specific the values in that column If given, returns results only matching the filters

  • columns_to_exclude (Optional[List[str]]) – Optional list of columns to exclude from the search results. The vector embedding column is excluded by default

Returns:

List of matching entities ordered by relevance.

Return type:

List[Dict[str, Any]]

abstract update(collection_name, where, update)#

Update existing entities that match the provided conditions.

Parameters:
  • collection_name (str) – Name of the collection to be updated.

  • where (Dict[str, Any]) – Filter criteria for the collection to update. The dictionary is composed of property name and value pairs to filter by with exact matches. Only entities matching all conditions in the dictionary will be updated. For example, {"name": "Fido", "breed": "Golden Retriever"} will match all Golden Retriever dogs named Fido.

  • update (Dict[str, Any]) – The update to apply to the matching entities in the collection.

Returns:

The updated entities, including any defaults or values not set in the update.

Return type:

list[dict]

In memory#

class wayflowcore.datastore.InMemoryDatastore(schema, id=None, search_configs=None, vector_configs=None, name=None, description=None, __metadata_info__=None)#

In-memory datastore for testing and development purposes.

This datastore implements basic functionalities of datastores, with the following properties:

  • All schema objects manipulated by the datastore must be fully defined using the Entity property. These entities are not persisted across instances of InMemoryDatastore or Python processes;

  • The underlying data cannot be shared across instances of this Datastore.

Important

This Datastore is meant only for testing and development purposes. Switch to a production-grade datastore (e.g., OracleDatabaseDatastore) before deploying an assistant.

Note

When this Datastore is serialized, only its configuration will be serialized, without any of the stored data.

Initialize an InMemoryDatastore.

Vector Config resolution Priority:
  1. VectorRetrieverConfig has a vectors attribute defined

  2. One of vector_configs’ collection name matches with input collection_name

  3. Vector column is inferred from Schema

Parameters:
  • schema (Dict[str, Entity]) – Mapping of collection names to entity definitions used by this datastore.

  • search_configs (Optional[List[SearchConfig]]) – List of search configurations for vector search capabilities. By default, it’s set as None. If no search config is given, the datastore will not support Search functionality.

  • vector_configs (Optional[List[VectorConfig]]) – List of vector configurations for vector generation and storage. By default, it’s set as None. If None, an implicit vector config will be created. Any operation on the Datastore might trigger the vector indices for these vector configs to be rebuilt again.

  • id (str | None)

  • name (str | None)

  • description (str | None)

  • __metadata_info__ (MetadataType | None)

Example

>>> from wayflowcore.datastore import Entity
>>> from wayflowcore.datastore.inmemory import InMemoryDatastore
>>> from wayflowcore.property import StringProperty, IntegerProperty

You can define one or more entities for your datastore and initialize it

>>> document = Entity(
...     properties={ "id": IntegerProperty(), "content": StringProperty(default_value="") }
... )
>>> datastore = InMemoryDatastore({"documents": document})

The InMemoryDatastore can create, list, update and delete entities. Creation can happen for single entities as well as multiples:

>>> datastore.create("documents", {"id": 1, "content": "The quick brown fox jumps over the lazy dog"})
{'content': 'The quick brown fox jumps over the lazy dog', 'id': 1}
>>> bulk_insert_docs = [
...     {"id": 2, "content": "The rat the cat the dog bit chased escaped."},
...     {"id": 3, "content": "More people have been to Russia than I have."}
... ]
>>> datastore.create("documents", bulk_insert_docs)
[{'content': 'The rat the cat the dog bit chased escaped.', 'id': 2}, {'content': 'More people have been to Russia than I have.', 'id': 3}]

Use where parameters to filter results when listing entities. When no matches are found, an empty list is returned Note that if multiple properties are set in the where dictionary, all of the values must match:

>>> datastore.list("documents", where={"id": 3})
[{'content': 'More people have been to Russia than I have.', 'id': 3}]
>>> datastore.list("documents", where={"id": 1, "content": "Not the content of document 1"})
[]

Use the limit parameter to reduce the size of the result set:

>>> datastore.list("documents", limit=1)
[{'content': 'The quick brown fox jumps over the lazy dog', 'id': 1}]

The same where parameter can be used to determine which entities should be updated or deleted:

>>> datastore.update("documents", where={"id": 1}, update={"content": "Will, will Will will Will Will's will?"})
[{'content': "Will, will Will will Will Will's will?", 'id': 1}]
>>> datastore.delete("documents", where={"id": 3})

Relational Datastore#

class wayflowcore.datastore._relational.RelationalDatastore(schema, engine, search_configs=None, vector_configs=None, name=None, description=None, id=None, __metadata_info__=None)#

A relational data store that supports querying data using SQL-like queries.

This class extends the Datastore class and adds support for querying data using SQL-like queries.

Initialize a RelationalDatastore

Parameters:
  • schema (Dict[str, Entity]) – Mapping of entity names to entities manipulated in this Datastore

  • engine (Engine) – SQLAlchemy engine used to connect to the relational database

  • search_configs (Optional[List[SearchConfig]]) – List of search configurations for vector search capabilities. By default, it’s set as None. If no search config is given, the datastore will not support Search functionality.

  • vector_configs (Optional[List[VectorConfig]]) – List of vector configurations for vector generation and storage. By default, it’s set as None. If None, a vector config will be inferred for each vector property found in the schema.

  • name (Optional[str]) – Name of the datastore

  • description (Optional[str]) – Description of the datastore

  • id (Optional[str]) – ID of the datastore

  • __metadata_info__ (MetadataType | None)

create(collection_name, entities)#

Create new entities of the specified type.

Parameters:
  • collection_name (str) – Name of the collection to create the new entities in.

  • entities (Union[Dict[str, Any], List[Dict[str, Any]]]) –

    One or more entities to create. Creating multiple entities at once may be beneficial for performance compared to executing multiple calls to create.

    Important

    When bulk-creating entities, all entities must contain the same set of properties. For example, if the Entity “employees” has properties “name” (required) and “salary” (optional), either all entities to create define only the name, or all define both name and salary. Some entities defining the salary and others relying on its default value is not supported.)

Returns:

The newly created entities, including any defaults not provided in the original entity. If the input entities were multiples, they will be returned as a list. Otherwise, a single dictionary with the newly created entity will be returned.

Return type:

list[dict] or dict

delete(collection_name, where)#

Delete entities based on the specified criteria.

Parameters:
  • collection_name (str) – Name of the collection in which entities will be deleted.

  • where (Dict[str, Any]) – Filter criteria for the entities to delete. The dictionary is composed of property name and value pairs to filter by with exact matches. Only entities matching all conditions in the dictionary will be deleted. For example, {"name": "Fido", "breed": "Golden Retriever"} will match all Golden Retriever dogs named Fido.

Return type:

None

describe()#

Get the descriptions of the schema associated with this Datastore.

Returns:

The description of the schema for the Datastore.

Return type:

dict[str, Entity]

list(collection_name, where=None, limit=None)#

Retrieve a list of entities in a collection based on the given criteria.

Parameters:
  • collection_name (str) – Name of the collection to list.

  • where (Optional[Dict[str, Any]]) – Filter criteria for the collection to list. The dictionary is composed of property name and value pairs to filter by with exact matches. Only entities matching all conditions in the dictionary will be listed. For example, {"name": "Fido", "breed": "Golden Retriever"} will match all Golden Retriever dogs named Fido.

  • limit (Optional[int]) – Maximum number of entities to retrieve, by default None (retrieve all entities).

Returns:

A list of entities matching the specified criteria.

Return type:

list[dict]

query(query, bind=None)#

Execute a query against the stored data.

This method can be useful to join data or use advanced filtering options not provided in Datastore.list.

Parameters:
  • query (str) – The query to execute, possibly parametrized with bind variables. The syntax for bind variables is :variable_name, where variable_name must be a key in the bind parameter of this method

  • bind (dict[str, Any]) – Bind variables for the query.

Return type:

List[Dict[str, Any]]

Returns:

  • The result of the query execution as a list of dictionaries

  • mapping column names in the select statement to their values.

  • .. note:: – If the select clause contains something other than column names, the literal values written in the column name are used as keys of the dictionary, e.g.: `sql SELECT COUNT(DISTINCT ID), MAX(salary) FROM employees ` will return a list with a single element, a dictionary with keys “COUNT(DISTINCT ID)” and “MAX(salary)”

update(collection_name, where, update)#

Update existing entities that match the provided conditions.

Parameters:
  • collection_name (str) – Name of the collection to be updated.

  • where (Dict[str, Any]) – Filter criteria for the collection to update. The dictionary is composed of property name and value pairs to filter by with exact matches. Only entities matching all conditions in the dictionary will be updated. For example, {"name": "Fido", "breed": "Golden Retriever"} will match all Golden Retriever dogs named Fido.

  • update (Dict[str, Any]) – The update to apply to the matching entities in the collection.

Returns:

The updated entities, including any defaults or values not set in the update.

Return type:

list[dict]

Oracle Database#

Important

The Oracle Database Datastore requires additional optional dependencies, which can be installed with the [datastore] installation option.

Note

By default (when using the OracleDatabaseConnectionConfig classes as-is), the python-oracledb client will use a thin connection to the database. If you want to use a thick connection (leveraging Oracle Instant Client), invoke oracledb.init_instant_client() before initializing any connection to the database. More information about thick and thin connection can be found in the python-oracledb documentation.

class wayflowcore.datastore.OracleDatabaseConnectionConfig(*, id=<factory>, __metadata_info__=<factory>, name='', description=None)#

Base class used for configuring connections to Oracle Database.

Parameters:
  • id (str)

  • __metadata_info__ (Dict[str, Any])

  • name (str)

  • description (str | None)

get_connection()#

Create a connection object from the configuration

Returns:

A python-oracledb connection object

Return type:

Any

class wayflowcore.datastore.TlsOracleDatabaseConnectionConfig(user, password, dsn, config_dir=None, *, id=<factory>, __metadata_info__=<factory>, name='', description=None)#

TLS Connection Configuration to Oracle Database.

Parameters:
  • user (str) – User used to connect to the database

  • password (str) – Password for the provided user

  • dsn (str) – Connection string for the database (e.g., created using oracledb.make_dsn)

  • config_dir (Optional[str]) – Configuration directory for the database connection. Set this if you are using an alias from your tnsnames.ora files as a DSN. Make sure that the specified DSN is appropriate for TLS connections (as the tnsnames.ora file in a downloaded wallet will only include DSN entries for mTLS connections).

  • id (str)

  • __metadata_info__ (Dict[str, Any])

  • name (str)

  • description (str | None)

config_dir: Optional[str] = None#
dsn: str#
password: str#
user: str#
class wayflowcore.datastore.MTlsOracleDatabaseConnectionConfig(config_dir, dsn, user, password, wallet_location, wallet_password, *, id=<factory>, __metadata_info__=<factory>, name='', description=None)#

Mutual-TLS Connection Configuration to Oracle Database.

Parameters:
  • config_dir (Optional[str]) – TNS Admin directory

  • dsn (str) – connection string for the database, or entry in the tnsnames.ora file

  • user (str) – connection string for the database

  • password (str) – password for the provided user

  • wallet_location (str) – location where the Oracle Database wallet is stored

  • wallet_password (str) – password for the provided wallet

  • id (str)

  • __metadata_info__ (Dict[str, Any])

  • name (str)

  • description (str | None)

config_dir: Optional[str]#
dsn: str#
password: str#
user: str#
wallet_location: str#
wallet_password: str#
class wayflowcore.datastore.OracleDatabaseDatastore(schema, connection_config, search_configs=None, vector_configs=None, name=None, description=None, id=None, __metadata_info__=None)#

Datastore that uses Oracle Database as the storage mechanism.

Important

This Datastore can only be used to connect to existing database schemas, with tables of interest already defined in the database.

Initialize an Oracle Database Datastore.

Search config resolution priority:
  1. Explicit collection match (config.collection_name == requested)

  2. Universal config (config.collection_name is None/empty)

Vector Config resolution Priority:
  1. VectorRetrieverConfig has a vectors attribute defined

  2. One of vector_configs’ collection name matches with input collection_name

  3. Vector column is inferred from Schema

Parameters:
  • schema (Dict[str, Entity]) – Mapping of collection names to entity definitions used by this datastore.

  • connection_config (OracleDatabaseConnectionConfig) – Configuration of connection parameters

  • search_configs (Optional[List[SearchConfig]]) – List of search configurations for vector search capabilities. By default, it’s set as None. If no search config is given, the datastore will not support Search functionality.

  • vector_configs (Optional[List[VectorConfig]]) – List of vector configurations for vector generation and storage. By default, it’s set as None. If None, a vector config will be inferred for each vector property found in the schema.

  • name (Optional[str]) – Name of the datastore

  • description (Optional[str]) – Description of the datastore

  • id (Optional[str]) – ID of the datastore

  • __metadata_info__ (MetadataType | None)

query(query, bind=None)#

Execute a query against the stored data.

This method can be useful to join data or use advanced filtering options not provided in Datastore.list.

Parameters:
  • query (str) – The query to execute, possibly parametrized with bind variables. The syntax for bind variables is :variable_name, where variable_name must be a key in the bind parameter of this method

  • bind (dict[str, Any]) – Bind variables for the query.

Return type:

List[Dict[str, Any]]

Returns:

  • The result of the query execution as a list of dictionaries

  • mapping column names in the select statement to their values.

  • .. note:: – If the select clause contains something other than column names, the literal values written in the column name are used as keys of the dictionary, e.g.: `sql SELECT COUNT(DISTINCT ID), MAX(salary) FROM employees ` will return a list with a single element, a dictionary with keys “COUNT(DISTINCT ID)” and “MAX(salary)”

Postgres Database#

Important

The Postgres Database Datastore requires additional optional dependencies, which can be installed with the [datastore] installation option.

class wayflowcore.datastore.PostgresDatabaseConnectionConfig(*, id=<factory>, __metadata_info__=<factory>, name='', description=None)#

Abstract class for a PostgreSQL connection.

Parameters:
  • id (str)

  • __metadata_info__ (Dict[str, Any])

  • name (str)

  • description (str | None)

abstract get_connection()#
Return type:

Engine

class wayflowcore.datastore.TlsPostgresDatabaseConnectionConfig(*, id=<factory>, __metadata_info__=<factory>, name='', description=None, user, password, url='localhost:5432', sslmode='require', sslcert=None, sslkey=None, sslrootcert=None, sslcrl=None)#

Configuration for a PostgreSQL connection with TLS/SSL support.

Parameters:
  • id (str)

  • __metadata_info__ (Dict[str, Any])

  • name (str)

  • description (str | None)

  • user (str)

  • password (str)

  • url (str)

  • sslmode (Literal['disable', 'allow', 'prefer', 'require', 'verify-ca', 'verify-full'])

  • sslcert (str | None)

  • sslkey (str | None)

  • sslrootcert (str | None)

  • sslcrl (str | None)

get_connection()#
Return type:

Engine

get_sqlalchemy_url()#

Builds a SQLAlchemy connection URL.

Return type:

str

password: str#

Password of the postgres database

sslcert: Optional[str] = None#

Path of the client SSL certificate, replacing the default ~/.postgresql/postgresql.crt. Ignored if an SSL connection is not made.

sslcrl: Optional[str] = None#

Path of the SSL server certificate revocation list (CRL). Certificates listed will be rejected while attempting to authenticate the server’s certificate.

sslkey: Optional[str] = None#

Path of the file containing the secret key used for the client certificate, replacing the default ~/.postgresql/postgresql.key. Ignored if an SSL connection is not made.

sslmode: Literal['disable', 'allow', 'prefer', 'require', 'verify-ca', 'verify-full'] = 'require'#

SSL mode for the PostgreSQL connection.

sslrootcert: Optional[str] = None#

Path of the file containing SSL certificate authority (CA) certificate(s). Used to verify server identity.

url: str = 'localhost:5432'#

URL to access the postgres database

user: str#

User of the postgres database

class wayflowcore.datastore.PostgresDatabaseDatastore(schema, connection_config, name=None, description=None, id=None, __metadata_info__=None)#

Datastore that uses Postgres Database as the storage mechanism.

Important

This Datastore can only be used to connect to existing database schemas, with tables of interest already defined in the database.

Initialize an Postgres Database Datastore.

Parameters:
  • schema (Dict[str, Entity]) – Mapping of collection names to entity definitions used by this datastore.

  • connection_config (PostgresDatabaseConnectionConfig) – Configuration of connection parameters

  • name (Optional[str]) – Name of the datastore

  • description (Optional[str]) – Description of the datastore

  • id (Optional[str]) – ID of the datastore

  • __metadata_info__ (MetadataType | None)

query(query, bind=None)#

Execute a query against the stored data.

This method can be useful to join data or use advanced filtering options not provided in Datastore.list.

Parameters:
  • query (str) – The query to execute, possibly parametrized with bind variables. The syntax for bind variables is :variable_name, where variable_name must be a key in the bind parameter of this method

  • bind (dict[str, Any]) – Bind variables for the query.

Return type:

List[Dict[str, Any]]

Returns:

  • The result of the query execution as a list of dictionaries

  • mapping column names in the select statement to their values.

  • .. note:: – If the select clause contains something other than column names, the literal values written in the column name are used as keys of the dictionary, e.g.: `sql SELECT COUNT(DISTINCT ID), MAX(salary) FROM employees ` will return a list with a single element, a dictionary with keys “COUNT(DISTINCT ID)” and “MAX(salary)”