Skip to main content

DataQuery

Represents a data query function within the Datagrok platform. DataQuery is a specialized Func that encapsulates the concept of querying a data source, such as an external SQL database, using a provided connection. This class combines the platform's general function capabilities with specific query execution details.

Examples

Creating and serializing a DataQuery:

>>> conn = DataConnection(name="Postgres", server="db.example.com", port=5432)
>>> dq = DataQuery(query="SELECT * FROM customers", connection=conn, name="Customer Query")
>>> dq.to_dict()
... {
... "id": None,
... "name": "Customer Query",
... "friendlyName": None,
... "createdOn": None,
... "updatedOn": None,
... "source": "data-query",
... "description": None,
... "params": [],
... "namespace": None,
... "tags": [],
... "options": {},
... "query": "SELECT * FROM customers",
... "connection": {...}
... }

Attributes

NameTypeDescription
querystrThe query text to be executed. Typically SQL, but may vary depending on the data source type. Can contains special annotations that will be parsed by platform into the func parameters
connectionDataConnectionThe connection definition for the data source on which the query will be executed. **kwargs Additional parameters passed to the base Func class, such as: - id : Optional[str] - name : Optional[str] - friendly_name : Optional[str] - description : Optional[str] - created_on : Optional[datetime] - updated_on : Optional[datetime] - params : Optional[List[FuncParam]] - namespace : Optional[str] - tags : Optional[List[str]] - options : Optional[Dict[str, Any]]
querystrThe raw query text.
connectionDataConnectionConnection settings for the target data source.

Methods

__init__()

to_dict()