otp.query (otq reference)#

class query(path, *config, **params)[source]#

Bases: object

Constructs a query object with a certain path. Keyword arguments specify query parameters.

You also can pass an instance of otp.query.config class as the second positional argument to specify a query.

Parameters
  • path (str) – path to an .otq file. If path is relative, then it’s assumed that file is located in one of the directories specified in OneTick OTQ_FILE_PATH configuration variable. If there are more than one query in the file, then its name should be specified in the format <path>::<query-name>. Also prefix remote://<database-name>:: can be used to specify if query is located on the remote server.

  • config – optional otp.query.config object.

  • params – parameters for the query.

Examples

>>> otp.query('/otqs/some.otq::some_query', PARAM1='val1', PARAM2=3.14)  
>>> otp.query('remote://DATABASE::/otqs/some.otq::some_query', PARAM1='val1', PARAM2=3.14)  
Raises

ValueError, TypeError

class config(output_columns=None)[source]#

Bases: object

Parameters

output_columns (str, list, dict, optional) –

The parameter defines what the outputs columns are. Default value is None that means no output fields after applying query for every output pin.

The input value means that output columns are the same as inputs for every output pin

A list of tuples allows to define output columns with their types; for example [(‘x’, int), (‘y’, float), …]. Applicable for every output pin.

A dict allows to specify output columns for every output pin.

Raises

TypeError, ValueError

special_values = {'input'}#
validate_list_item(item)[source]#
validate_columns(columns)[source]#
get_output_columns_for_pin(out_pin_name)[source]#
apply(out_pin_name, src)[source]#
to_eval_string()[source]#
update_params(**new_params)[source]#
property str_params#