Api

class composapy.queryview.api.QueryView

A wrapper class for queryview operations.

static driver(key: KeyObject | None = None, timeout: int | None = None, validate_query: bool = False, interactive: bool = False) QueryViewObject

Retrieve a queryview driver object, key is optional argument, but will need to call connect with key as argument to run a query.

from composapy.key.api import Key
from composapy.queryview.api import QueryView

key = Key.get(123456)  # KeyObject(id=123456)

# Create driver and connect...
driver = QueryView.driver()  # QueryViewObject(name=some_name, key=None)
driver.connect(key)

# ... or use the key as method argument to automatically connect.
driver = QueryView.driver(key)  # QueryViewObject(name=some_name, key=some_key)

# If you already have a KeyObject registered, there is no need to pass in the key
# or call connect with it; the driver will be created with a registered key by default.
Parameters:
  • key – KeyObject retrieved with the Composable Key api

  • timeout – optional integer timeout value (in seconds) for the query driver. This will apply to all queries executed with this driver unless an alternate timeout value is specified when calling the driver.run() method

  • validate_query – boolean indicating whether to apply a pre-compilation step to validate SQL queries run with the driver. This often provides more informative error output but can be disabled for maximal query performance.

  • interactive – when enabled, query results will be rendered as an interactive DataTable with server-side pagination.

static run(qv_id: int, inputs: Dict[str, any] = None, interactive: bool = False) pd.DataFrame | ITableResult

Run a saved QueryView resource, returning the results as a Pandas DataFrame. Will use the currently saved QueryView query and connection settings. Note, this will not use your currently registered key as the query connection settings.

from composapy.queryview.api import QueryView

df = QueryView.run(123456)

# Or, if the QueryView has inputs, you can pass them in as an optional argument
# Literal inputs should be a string-string key-value pair: "Display Name": "Value"
# Filter inputs can be a string-string key-value pair or a string-tuple pair: "Display Name": ("Value", "Operator")
df = QueryView.run(123456, inputs={"Display Name 1": "Value 1", "Display Name 2": ("Value 2", ">=")})
Parameters:
  • qv_id – QueryView id, can be found in the url of your QueryView resource.

  • inputs – Dictionary of filter/literal inputs to use for the query execution.

  • interactive – when enabled, query results will be rendered as an interactive DataTable with pagination.