otp.query (onetick.query reference)#
- class query(path, *config, **params)#
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 prefixremote://<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) <onetick.py.sources.query object at ...>
- Raises
- class config(output_columns=None)#
Bases:
object
The config allows to specify different query options.
- 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 pinA 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
- special_values = {'input'}#
- validate_list_item(item)#
- validate_columns(columns)#
- get_output_columns_for_pin(out_pin_name)#
- apply(out_pin_name, src)#
Applying specified logic on a certain object. Used internally in the functions.apply_query
- to_eval_string()#
Converts query object to eval string
- update_params(**new_params)#
- property str_params#
Query parameters converted to string