{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Query ASAM ODS Server"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this example Notebook, we show you how to query (instance) data from your ASAM ODS Server.\n",
"\n",
"The first sections are on initializing and connecting. The fun starts with \"Query Instances\"."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Dependencies for this notebook"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The [ASAM ODSBox](https://pypi.org/project/odsbox/) contains some functionality that wraps the ODS HTTP API making using Python easier ;-)\n",
"\n",
"It contains:\n",
"- http wrapper implemented using protobuf and requests\n",
"- JAQueL implementation that converts MongoDB style JSON queries into a native ODS SelectStatement\n",
"- utility that converts ODS DataMatrices into pandas.DataFrame\n",
"\n",
"> All examples are using the JAQueL query style to help you getting started.\n",
"> Use `jaquel_to_select_statement` to convert JAQueL to a native ODS `SelectStatement`. "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"try: \n",
" import odsbox\n",
"except:\n",
" !pip install odsbox \n",
"\n",
"from odsbox.con_i import ConI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## ASAM ODS Queries"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Establish session"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ODS HTTP API is a session based API. The session ID is called conI in the ODS documentation. The [ASAM ODSBox](https://pypi.org/project/odsbox/) uses con_i as API object representing the session. Close this session to release the connection license. Otherwise the session will be auto closed after 30 minutes of inactivity."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"con_i = ConI(url='http://79.140.180.128:10032/api', auth=('Demo','mdm'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Query Instances"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Query Units"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Engineering units are contained in every ASAM ODS server, so we can use them to get started:\n",
"Lets search for all units in this server"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Unit.Id | \n",
" Unit.Name | \n",
" Unit.MimeType | \n",
" Unit.Description | \n",
" Unit.DateCreated | \n",
" Unit.Factor | \n",
" Unit.Offset | \n",
" Unit.dB | \n",
" Unit.dB_reference_factor | \n",
" Unit.PhysDimension | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1 | \n",
" m | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 3 | \n",
"
\n",
" \n",
" 1 | \n",
" 2 | \n",
" kg | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 2 | \n",
"
\n",
" \n",
" 2 | \n",
" 3 | \n",
" s | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 1 | \n",
"
\n",
" \n",
" 3 | \n",
" 4 | \n",
" A | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 4 | \n",
"
\n",
" \n",
" 4 | \n",
" 5 | \n",
" K | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 5 | \n",
"
\n",
" \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
" ... | \n",
"
\n",
" \n",
" 95 | \n",
" 96 | \n",
" kat/m^3 | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 71 | \n",
"
\n",
" \n",
" 96 | \n",
" 97 | \n",
" Sv/s | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 63 | \n",
"
\n",
" \n",
" 97 | \n",
" 98 | \n",
" A*s/kg | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 64 | \n",
"
\n",
" \n",
" 98 | \n",
" 99 | \n",
" °C | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 73 | \n",
"
\n",
" \n",
" 99 | \n",
" 100 | \n",
" rpm | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 73 | \n",
"
\n",
" \n",
"
\n",
"
100 rows × 10 columns
\n",
"
"
],
"text/plain": [
" Unit.Id Unit.Name Unit.MimeType Unit.Description \\\n",
"0 1 m application/x-asam.aounit \n",
"1 2 kg application/x-asam.aounit \n",
"2 3 s application/x-asam.aounit \n",
"3 4 A application/x-asam.aounit \n",
"4 5 K application/x-asam.aounit \n",
".. ... ... ... ... \n",
"95 96 kat/m^3 application/x-asam.aounit \n",
"96 97 Sv/s application/x-asam.aounit \n",
"97 98 A*s/kg application/x-asam.aounit \n",
"98 99 °C application/x-asam.aounit \n",
"99 100 rpm application/x-asam.aounit \n",
"\n",
" Unit.DateCreated Unit.Factor Unit.Offset Unit.dB \\\n",
"0 19700101000000 1.0 0.0 False \n",
"1 19700101000000 1.0 0.0 False \n",
"2 19700101000000 1.0 0.0 False \n",
"3 19700101000000 1.0 0.0 False \n",
"4 19700101000000 1.0 0.0 False \n",
".. ... ... ... ... \n",
"95 19700101000000 1.0 0.0 False \n",
"96 19700101000000 1.0 0.0 False \n",
"97 19700101000000 1.0 0.0 False \n",
"98 19700101000000 1.0 0.0 False \n",
"99 19700101000000 1.0 0.0 False \n",
"\n",
" Unit.dB_reference_factor Unit.PhysDimension \n",
"0 0.0 3 \n",
"1 0.0 2 \n",
"2 0.0 1 \n",
"3 0.0 4 \n",
"4 0.0 5 \n",
".. ... ... \n",
"95 0.0 71 \n",
"96 0.0 63 \n",
"97 0.0 64 \n",
"98 0.0 73 \n",
"99 0.0 73 \n",
"\n",
"[100 rows x 10 columns]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# There is always one Entity derived from AoUnit\n",
"con_i.query_data({\n",
" \"AoUnit\":{}\n",
" })"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In our first query we've used the base name 'AoUnit' - so this query works on every ODS server. \n",
"In our query result above we see that the entity derived from 'AoUnit' is called 'Unit'. So we can use this directly."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Unit.Id | \n",
" Unit.Name | \n",
" Unit.MimeType | \n",
" Unit.Description | \n",
" Unit.DateCreated | \n",
" Unit.Factor | \n",
" Unit.Offset | \n",
" Unit.dB | \n",
" Unit.dB_reference_factor | \n",
" Unit.PhysDimension | \n",
"
\n",
" \n",
" \n",
" \n",
" 95 | \n",
" 96 | \n",
" kat/m^3 | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 71 | \n",
"
\n",
" \n",
" 96 | \n",
" 97 | \n",
" Sv/s | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 63 | \n",
"
\n",
" \n",
" 97 | \n",
" 98 | \n",
" A*s/kg | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 64 | \n",
"
\n",
" \n",
" 98 | \n",
" 99 | \n",
" °C | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 73 | \n",
"
\n",
" \n",
" 99 | \n",
" 100 | \n",
" rpm | \n",
" application/x-asam.aounit | \n",
" | \n",
" 19700101000000 | \n",
" 1.0 | \n",
" 0.0 | \n",
" False | \n",
" 0.0 | \n",
" 73 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Unit.Id Unit.Name Unit.MimeType Unit.Description \\\n",
"95 96 kat/m^3 application/x-asam.aounit \n",
"96 97 Sv/s application/x-asam.aounit \n",
"97 98 A*s/kg application/x-asam.aounit \n",
"98 99 °C application/x-asam.aounit \n",
"99 100 rpm application/x-asam.aounit \n",
"\n",
" Unit.DateCreated Unit.Factor Unit.Offset Unit.dB \\\n",
"95 19700101000000 1.0 0.0 False \n",
"96 19700101000000 1.0 0.0 False \n",
"97 19700101000000 1.0 0.0 False \n",
"98 19700101000000 1.0 0.0 False \n",
"99 19700101000000 1.0 0.0 False \n",
"\n",
" Unit.dB_reference_factor Unit.PhysDimension \n",
"95 0.0 71 \n",
"96 0.0 63 \n",
"97 0.0 64 \n",
"98 0.0 73 \n",
"99 0.0 73 "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"Unit\":{}\n",
" }).tail()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now lets narrow down the list to the interesting attributes like 'name', 'factor' and 'offset'. And instead of its id we want to know the 'name' of the referenced physical dimension."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Unit.Name | \n",
" Unit.Factor | \n",
" Unit.Offset | \n",
" PhysDimension.Name | \n",
"
\n",
" \n",
" \n",
" \n",
" 95 | \n",
" kat/m^3 | \n",
" 1.0 | \n",
" 0.0 | \n",
" catalytic_concentration | \n",
"
\n",
" \n",
" 96 | \n",
" Sv/s | \n",
" 1.0 | \n",
" 0.0 | \n",
" equivalent_dose_rate | \n",
"
\n",
" \n",
" 97 | \n",
" A*s/kg | \n",
" 1.0 | \n",
" 0.0 | \n",
" exposure_as_a_quantity | \n",
"
\n",
" \n",
" 98 | \n",
" °C | \n",
" 1.0 | \n",
" 0.0 | \n",
" unknown | \n",
"
\n",
" \n",
" 99 | \n",
" rpm | \n",
" 1.0 | \n",
" 0.0 | \n",
" unknown | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Unit.Name Unit.Factor Unit.Offset PhysDimension.Name\n",
"95 kat/m^3 1.0 0.0 catalytic_concentration\n",
"96 Sv/s 1.0 0.0 equivalent_dose_rate\n",
"97 A*s/kg 1.0 0.0 exposure_as_a_quantity\n",
"98 °C 1.0 0.0 unknown\n",
"99 rpm 1.0 0.0 unknown"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"Unit\":{},\n",
" \"$attributes\":{\n",
" \"name\":1,\n",
" \"factor\":1,\n",
" \"offset\":1,\n",
" \"PhysDimension.name\":1\n",
" }\n",
" }).tail()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In addition to the 'name' of the physical dimension, we are also interested in the lenght exponent."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Unit.Name | \n",
" Unit.Factor | \n",
" Unit.Offset | \n",
" PhysDimension.Name | \n",
" PhysDimension.Length | \n",
"
\n",
" \n",
" \n",
" \n",
" 95 | \n",
" kat/m^3 | \n",
" 1.0 | \n",
" 0.0 | \n",
" catalytic_concentration | \n",
" -3 | \n",
"
\n",
" \n",
" 96 | \n",
" Sv/s | \n",
" 1.0 | \n",
" 0.0 | \n",
" equivalent_dose_rate | \n",
" 2 | \n",
"
\n",
" \n",
" 97 | \n",
" A*s/kg | \n",
" 1.0 | \n",
" 0.0 | \n",
" exposure_as_a_quantity | \n",
" 0 | \n",
"
\n",
" \n",
" 98 | \n",
" °C | \n",
" 1.0 | \n",
" 0.0 | \n",
" unknown | \n",
" 0 | \n",
"
\n",
" \n",
" 99 | \n",
" rpm | \n",
" 1.0 | \n",
" 0.0 | \n",
" unknown | \n",
" 0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Unit.Name Unit.Factor Unit.Offset PhysDimension.Name \\\n",
"95 kat/m^3 1.0 0.0 catalytic_concentration \n",
"96 Sv/s 1.0 0.0 equivalent_dose_rate \n",
"97 A*s/kg 1.0 0.0 exposure_as_a_quantity \n",
"98 °C 1.0 0.0 unknown \n",
"99 rpm 1.0 0.0 unknown \n",
"\n",
" PhysDimension.Length \n",
"95 -3 \n",
"96 2 \n",
"97 0 \n",
"98 0 \n",
"99 0 "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"Unit\":{},\n",
" \"$attributes\":{\n",
" \"name\":1,\n",
" \"factor\":1,\n",
" \"offset\":1,\n",
" \"PhysDimension.name\":1,\n",
" \"PhysDimension.length_exp\":1\n",
" }\n",
" }).tail()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ok, and if I'm only interested in Units with a physical dimension with a length exponent of '1'?"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Unit.Name | \n",
" Unit.Factor | \n",
" Unit.Offset | \n",
" PhysDimension.Name | \n",
" PhysDimension.Length | \n",
"
\n",
" \n",
" \n",
" \n",
" 4 | \n",
" N | \n",
" 1.0 | \n",
" 0.0 | \n",
" force | \n",
" 1 | \n",
"
\n",
" \n",
" 5 | \n",
" N/s | \n",
" 1.0 | \n",
" 0.0 | \n",
" momentum | \n",
" 1 | \n",
"
\n",
" \n",
" 6 | \n",
" W/m*K | \n",
" 1.0 | \n",
" 0.0 | \n",
" thermal_conductivity | \n",
" 1 | \n",
"
\n",
" \n",
" 7 | \n",
" V/m | \n",
" 1.0 | \n",
" 0.0 | \n",
" electric_field_strength | \n",
" 1 | \n",
"
\n",
" \n",
" 8 | \n",
" H/m | \n",
" 1.0 | \n",
" 0.0 | \n",
" permeability | \n",
" 1 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Unit.Name Unit.Factor Unit.Offset PhysDimension.Name \\\n",
"4 N 1.0 0.0 force \n",
"5 N/s 1.0 0.0 momentum \n",
"6 W/m*K 1.0 0.0 thermal_conductivity \n",
"7 V/m 1.0 0.0 electric_field_strength \n",
"8 H/m 1.0 0.0 permeability \n",
"\n",
" PhysDimension.Length \n",
"4 1 \n",
"5 1 \n",
"6 1 \n",
"7 1 \n",
"8 1 "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"Unit\":{\"PhysDimension.length_exp\":1},\n",
" \"$attributes\":{\n",
" \"name\":1,\n",
" \"factor\":1,\n",
" \"offset\":1,\n",
" \"PhysDimension.name\":1,\n",
" \"PhysDimension.length_exp\":1\n",
" }\n",
" }).tail()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
".... or in those, where the 'name' of the physical dimension is 'length' ..."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Unit.Name | \n",
" Unit.Factor | \n",
" Unit.Offset | \n",
" PhysDimension.Name | \n",
" PhysDimension.Length | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" m | \n",
" 1.0 | \n",
" 0.0 | \n",
" length | \n",
" 1 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Unit.Name Unit.Factor Unit.Offset PhysDimension.Name PhysDimension.Length\n",
"0 m 1.0 0.0 length 1"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"Unit\":{\"PhysDimension.name\":\"length\"},\n",
" \"$attributes\":{\n",
" \"name\":1,\n",
" \"factor\":1,\n",
" \"offset\":1,\n",
" \"PhysDimension.name\":1,\n",
" \"PhysDimension.length_exp\":1\n",
" }\n",
" }).tail()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"... we can also make it easier getting a group of attributes of the same type in return... "
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Unit.Name | \n",
" Unit.Factor | \n",
" Unit.Offset | \n",
" PhysDimension.Name | \n",
" PhysDimension.Length | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" m | \n",
" 1.0 | \n",
" 0.0 | \n",
" length | \n",
" 1 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Unit.Name Unit.Factor Unit.Offset PhysDimension.Name PhysDimension.Length\n",
"0 m 1.0 0.0 length 1"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"Unit\":{\"PhysDimension.name\":\"length\"},\n",
" \"$attributes\":{\n",
" \"name\":1,\n",
" \"factor\":1,\n",
" \"offset\":1,\n",
" \"PhysDimension\": {\n",
" \"name\":1,\n",
" \"length_exp\":1\n",
" }\n",
" }\n",
" }).tail()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"All queries have used 'equal' as implicit operator before. Now lets use 'like' instead."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Unit.Name | \n",
" Unit.Factor | \n",
" Unit.Offset | \n",
" PhysDimension.Name | \n",
" PhysDimension.Length | \n",
"
\n",
" \n",
" \n",
" \n",
" 3 | \n",
" kg/m^3 | \n",
" 1.0 | \n",
" 0.0 | \n",
" density | \n",
" -3 | \n",
"
\n",
" \n",
" 4 | \n",
" km/h | \n",
" 3.6 | \n",
" 0.0 | \n",
" velocity | \n",
" 1 | \n",
"
\n",
" \n",
" 5 | \n",
" kW*h | \n",
" 3600000.0 | \n",
" 0.0 | \n",
" energy | \n",
" 2 | \n",
"
\n",
" \n",
" 6 | \n",
" kat | \n",
" 1.0 | \n",
" 0.0 | \n",
" catalytic_activity | \n",
" 0 | \n",
"
\n",
" \n",
" 7 | \n",
" kat/m^3 | \n",
" 1.0 | \n",
" 0.0 | \n",
" catalytic_concentration | \n",
" -3 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Unit.Name Unit.Factor Unit.Offset PhysDimension.Name \\\n",
"3 kg/m^3 1.0 0.0 density \n",
"4 km/h 3.6 0.0 velocity \n",
"5 kW*h 3600000.0 0.0 energy \n",
"6 kat 1.0 0.0 catalytic_activity \n",
"7 kat/m^3 1.0 0.0 catalytic_concentration \n",
"\n",
" PhysDimension.Length \n",
"3 -3 \n",
"4 1 \n",
"5 2 \n",
"6 0 \n",
"7 -3 "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"Unit\":{\n",
" \"name\":{\"$like\":\"k*\"}\n",
" },\n",
" \"$attributes\":{\n",
" \"name\":1,\n",
" \"factor\":1,\n",
" \"offset\":1,\n",
" \"PhysDimension\": {\n",
" \"name\":1,\n",
" \"length_exp\":1\n",
" }\n",
" }\n",
" }).tail()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Query Hierarchy elements\n",
"\n",
"When you think about using ASAM ODS as a tool to manage and harmonize measurement data files like CSV, XLSX, MDF4, ... you can think of the following data model:\n",
"\n",
"- *file* -> 'TestStep'\n",
"- *group*, *sheet* -> 'MeaResult'\n",
"- *channel*, *column* -> 'MeaQuantity'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"So lets query for them and reduce the maximal amount returned to a fix number - here: 5."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" TestStep.Id | \n",
" TestStep.Name | \n",
" TestStep.MimeType | \n",
" TestStep.Description | \n",
" TestStep.DateCreated | \n",
" TestStep.Optional | \n",
" TestStep.Sortindex | \n",
" TestStep.MDMLinks | \n",
" TestStep.Test | \n",
" TestStep.TplTestStep | \n",
" TestStep.TestEquipment | \n",
" TestStep.UnitUnderTest | \n",
" TestStep.TestSequence | \n",
" TestStep.Classification | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" application/x-asam.aosubtest.teststep | \n",
" | \n",
" 19700101000000 | \n",
" False | \n",
" 0 | \n",
" [] | \n",
" 1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" TestStep.Id TestStep.Name \\\n",
"0 1 ElectricMotorTemperatureTest \n",
"\n",
" TestStep.MimeType TestStep.Description \\\n",
"0 application/x-asam.aosubtest.teststep \n",
"\n",
" TestStep.DateCreated TestStep.Optional TestStep.Sortindex \\\n",
"0 19700101000000 False 0 \n",
"\n",
" TestStep.MDMLinks TestStep.Test TestStep.TplTestStep \\\n",
"0 [] 1 0 \n",
"\n",
" TestStep.TestEquipment TestStep.UnitUnderTest TestStep.TestSequence \\\n",
"0 0 0 0 \n",
"\n",
" TestStep.Classification \n",
"0 0 "
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"TestStep\": {},\n",
" \"$options\": { \"$rowlimit\": 5 }\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" MeaResult.Id | \n",
" MeaResult.Name | \n",
" MeaResult.MimeType | \n",
" MeaResult.Description | \n",
" MeaResult.DateCreated | \n",
" MeaResult.MeasurementBegin | \n",
" MeaResult.MeasurementEnd | \n",
" MeaResult.MDMLinks | \n",
" MeaResult.TestStep | \n",
" MeaResult.TestEquipment | \n",
" MeaResult.UnitUnderTest | \n",
" MeaResult.TestSequence | \n",
" MeaResult.Classification | \n",
" MeaResult.TplMeaResult | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1 | \n",
" Profile_02 | \n",
" application/x-asam.aomeasurement | \n",
" | \n",
" 19700101000000 | \n",
" 20240607000000 | \n",
" 20240607000000 | \n",
" [] | \n",
" 1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
"
\n",
" \n",
" 1 | \n",
" 2 | \n",
" Profile_03 | \n",
" application/x-asam.aomeasurement | \n",
" | \n",
" 19700101000000 | \n",
" 20240713000000 | \n",
" 20240713000000 | \n",
" [] | \n",
" 1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
"
\n",
" \n",
" 2 | \n",
" 3 | \n",
" Profile_04 | \n",
" application/x-asam.aomeasurement | \n",
" | \n",
" 19700101000000 | \n",
" 20240627000000 | \n",
" 20240627000000 | \n",
" [] | \n",
" 1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
"
\n",
" \n",
" 3 | \n",
" 4 | \n",
" Profile_05 | \n",
" application/x-asam.aomeasurement | \n",
" | \n",
" 19700101000000 | \n",
" 20240709000000 | \n",
" 20240709000000 | \n",
" [] | \n",
" 1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
"
\n",
" \n",
" 4 | \n",
" 5 | \n",
" Profile_06 | \n",
" application/x-asam.aomeasurement | \n",
" | \n",
" 19700101000000 | \n",
" 20240515000000 | \n",
" 20240515000000 | \n",
" [] | \n",
" 1 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
" 0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" MeaResult.Id MeaResult.Name MeaResult.MimeType \\\n",
"0 1 Profile_02 application/x-asam.aomeasurement \n",
"1 2 Profile_03 application/x-asam.aomeasurement \n",
"2 3 Profile_04 application/x-asam.aomeasurement \n",
"3 4 Profile_05 application/x-asam.aomeasurement \n",
"4 5 Profile_06 application/x-asam.aomeasurement \n",
"\n",
" MeaResult.Description MeaResult.DateCreated MeaResult.MeasurementBegin \\\n",
"0 19700101000000 20240607000000 \n",
"1 19700101000000 20240713000000 \n",
"2 19700101000000 20240627000000 \n",
"3 19700101000000 20240709000000 \n",
"4 19700101000000 20240515000000 \n",
"\n",
" MeaResult.MeasurementEnd MeaResult.MDMLinks MeaResult.TestStep \\\n",
"0 20240607000000 [] 1 \n",
"1 20240713000000 [] 1 \n",
"2 20240627000000 [] 1 \n",
"3 20240709000000 [] 1 \n",
"4 20240515000000 [] 1 \n",
"\n",
" MeaResult.TestEquipment MeaResult.UnitUnderTest MeaResult.TestSequence \\\n",
"0 0 0 0 \n",
"1 0 0 0 \n",
"2 0 0 0 \n",
"3 0 0 0 \n",
"4 0 0 0 \n",
"\n",
" MeaResult.Classification MeaResult.TplMeaResult \n",
"0 0 0 \n",
"1 0 0 \n",
"2 0 0 \n",
"3 0 0 \n",
"4 0 0 "
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"MeaResult\": {},\n",
" \"$options\": { \"$rowlimit\": 5 }\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" MeaQuantity.Id | \n",
" MeaQuantity.Name | \n",
" MeaQuantity.MimeType | \n",
" MeaQuantity.Description | \n",
" MeaQuantity.Interpolation | \n",
" MeaQuantity.DataType | \n",
" MeaQuantity.Rank | \n",
" MeaQuantity.Dimension | \n",
" MeaQuantity.TypeSize | \n",
" MeaQuantity.Minimum | \n",
" MeaQuantity.Maximum | \n",
" MeaQuantity.Average | \n",
" MeaQuantity.Deviation | \n",
" MeaQuantity.non_reference_channel_name | \n",
" MeaQuantity.reference_channel_name | \n",
" MeaQuantity.MeaResult | \n",
" MeaQuantity.Quantity | \n",
" MeaQuantity.Unit | \n",
" MeaQuantity.Classification | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1 | \n",
" Time | \n",
" application/x-asam.aomeasurementquantity | \n",
" Time measured in 2 Hz | \n",
" 0 | \n",
" 7 | \n",
" 0 | \n",
" [] | \n",
" 0 | \n",
" 0.000000 | \n",
" 9678.500000 | \n",
" 4839.250000 | \n",
" 2794.086631 | \n",
" | \n",
" | \n",
" 1 | \n",
" 0 | \n",
" 3 | \n",
" 0 | \n",
"
\n",
" \n",
" 1 | \n",
" 2 | \n",
" U_q | \n",
" application/x-asam.aomeasurementquantity | \n",
" Voltage q-component measurement in dq-coordinates | \n",
" 0 | \n",
" 7 | \n",
" 0 | \n",
" [] | \n",
" 0 | \n",
" 3.919605 | \n",
" 8.798512 | \n",
" 5.894508 | \n",
" 2.231838 | \n",
" | \n",
" | \n",
" 1 | \n",
" 0 | \n",
" 76 | \n",
" 0 | \n",
"
\n",
" \n",
" 2 | \n",
" 3 | \n",
" Coolant | \n",
" application/x-asam.aomeasurementquantity | \n",
" Coolant temperature | \n",
" 0 | \n",
" 7 | \n",
" 0 | \n",
" [] | \n",
" 0 | \n",
" 15.594865 | \n",
" 19.774647 | \n",
" 18.542054 | \n",
" 0.328558 | \n",
" | \n",
" | \n",
" 1 | \n",
" 0 | \n",
" 82 | \n",
" 0 | \n",
"
\n",
" \n",
" 3 | \n",
" 4 | \n",
" Stator_winding | \n",
" application/x-asam.aomeasurementquantity | \n",
" Stator winding temperature measured with therm... | \n",
" 0 | \n",
" 7 | \n",
" 0 | \n",
" [] | \n",
" 0 | \n",
" 19.428793 | \n",
" 103.282516 | \n",
" 51.110270 | \n",
" 37.978699 | \n",
" | \n",
" | \n",
" 1 | \n",
" 0 | \n",
" 82 | \n",
" 0 | \n",
"
\n",
" \n",
" 4 | \n",
" 5 | \n",
" U_d | \n",
" application/x-asam.aomeasurementquantity | \n",
" Voltage d-component measurement in dq-coordinates | \n",
" 0 | \n",
" 7 | \n",
" 0 | \n",
" [] | \n",
" 0 | \n",
" -9.820481 | \n",
" 1.701082 | \n",
" -2.815422 | \n",
" 5.474471 | \n",
" | \n",
" | \n",
" 1 | \n",
" 0 | \n",
" 76 | \n",
" 0 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" MeaQuantity.Id MeaQuantity.Name MeaQuantity.MimeType \\\n",
"0 1 Time application/x-asam.aomeasurementquantity \n",
"1 2 U_q application/x-asam.aomeasurementquantity \n",
"2 3 Coolant application/x-asam.aomeasurementquantity \n",
"3 4 Stator_winding application/x-asam.aomeasurementquantity \n",
"4 5 U_d application/x-asam.aomeasurementquantity \n",
"\n",
" MeaQuantity.Description \\\n",
"0 Time measured in 2 Hz \n",
"1 Voltage q-component measurement in dq-coordinates \n",
"2 Coolant temperature \n",
"3 Stator winding temperature measured with therm... \n",
"4 Voltage d-component measurement in dq-coordinates \n",
"\n",
" MeaQuantity.Interpolation MeaQuantity.DataType MeaQuantity.Rank \\\n",
"0 0 7 0 \n",
"1 0 7 0 \n",
"2 0 7 0 \n",
"3 0 7 0 \n",
"4 0 7 0 \n",
"\n",
" MeaQuantity.Dimension MeaQuantity.TypeSize MeaQuantity.Minimum \\\n",
"0 [] 0 0.000000 \n",
"1 [] 0 3.919605 \n",
"2 [] 0 15.594865 \n",
"3 [] 0 19.428793 \n",
"4 [] 0 -9.820481 \n",
"\n",
" MeaQuantity.Maximum MeaQuantity.Average MeaQuantity.Deviation \\\n",
"0 9678.500000 4839.250000 2794.086631 \n",
"1 8.798512 5.894508 2.231838 \n",
"2 19.774647 18.542054 0.328558 \n",
"3 103.282516 51.110270 37.978699 \n",
"4 1.701082 -2.815422 5.474471 \n",
"\n",
" MeaQuantity.non_reference_channel_name MeaQuantity.reference_channel_name \\\n",
"0 \n",
"1 \n",
"2 \n",
"3 \n",
"4 \n",
"\n",
" MeaQuantity.MeaResult MeaQuantity.Quantity MeaQuantity.Unit \\\n",
"0 1 0 3 \n",
"1 1 0 76 \n",
"2 1 0 82 \n",
"3 1 0 82 \n",
"4 1 0 76 \n",
"\n",
" MeaQuantity.Classification \n",
"0 0 \n",
"1 0 \n",
"2 0 \n",
"3 0 \n",
"4 0 "
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"MeaQuantity\": {},\n",
" \"$options\": { \"$rowlimit\": 5 }\n",
"})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Get parent properties\n",
"Consider you're looking for *columns* (MeaQuantity), but also being interested to which *sheet* (MeaResult) and *file* (TestStep) they belong, the following query will give you an idea how this works... "
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" MeaQuantity.Id | \n",
" MeaQuantity.Name | \n",
" MeaResult.Id | \n",
" MeaResult.Name | \n",
" TestStep.Id | \n",
" TestStep.Name | \n",
" Unit.Name | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1 | \n",
" Time | \n",
" 1 | \n",
" Profile_02 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" s | \n",
"
\n",
" \n",
" 1 | \n",
" 2 | \n",
" U_q | \n",
" 1 | \n",
" Profile_02 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" V | \n",
"
\n",
" \n",
" 2 | \n",
" 3 | \n",
" Coolant | \n",
" 1 | \n",
" Profile_02 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" gradC | \n",
"
\n",
" \n",
" 3 | \n",
" 4 | \n",
" Stator_winding | \n",
" 1 | \n",
" Profile_02 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" gradC | \n",
"
\n",
" \n",
" 4 | \n",
" 5 | \n",
" U_d | \n",
" 1 | \n",
" Profile_02 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" V | \n",
"
\n",
" \n",
" 5 | \n",
" 6 | \n",
" Stator_tooth | \n",
" 1 | \n",
" Profile_02 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" gradC | \n",
"
\n",
" \n",
" 6 | \n",
" 7 | \n",
" Motor_speed | \n",
" 1 | \n",
" Profile_02 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" 1/min | \n",
"
\n",
" \n",
" 7 | \n",
" 8 | \n",
" I_d | \n",
" 1 | \n",
" Profile_02 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" A | \n",
"
\n",
" \n",
" 8 | \n",
" 9 | \n",
" I_q | \n",
" 1 | \n",
" Profile_02 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" A | \n",
"
\n",
" \n",
" 9 | \n",
" 10 | \n",
" Pm | \n",
" 1 | \n",
" Profile_02 | \n",
" 1 | \n",
" ElectricMotorTemperatureTest | \n",
" gradC | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" MeaQuantity.Id MeaQuantity.Name MeaResult.Id MeaResult.Name TestStep.Id \\\n",
"0 1 Time 1 Profile_02 1 \n",
"1 2 U_q 1 Profile_02 1 \n",
"2 3 Coolant 1 Profile_02 1 \n",
"3 4 Stator_winding 1 Profile_02 1 \n",
"4 5 U_d 1 Profile_02 1 \n",
"5 6 Stator_tooth 1 Profile_02 1 \n",
"6 7 Motor_speed 1 Profile_02 1 \n",
"7 8 I_d 1 Profile_02 1 \n",
"8 9 I_q 1 Profile_02 1 \n",
"9 10 Pm 1 Profile_02 1 \n",
"\n",
" TestStep.Name Unit.Name \n",
"0 ElectricMotorTemperatureTest s \n",
"1 ElectricMotorTemperatureTest V \n",
"2 ElectricMotorTemperatureTest gradC \n",
"3 ElectricMotorTemperatureTest gradC \n",
"4 ElectricMotorTemperatureTest V \n",
"5 ElectricMotorTemperatureTest gradC \n",
"6 ElectricMotorTemperatureTest 1/min \n",
"7 ElectricMotorTemperatureTest A \n",
"8 ElectricMotorTemperatureTest A \n",
"9 ElectricMotorTemperatureTest gradC "
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"MeaQuantity\": {},\n",
" \"$attributes\": {\n",
" \"Id\": 1,\n",
" \"Name\": 1,\n",
" \"MeaResult\": {\n",
" \"Id\": 1,\n",
" \"Name\": 1,\n",
" \"TestStep\": {\n",
" \"Id\": 1,\n",
" \"Name\": 1\n",
" }\n",
" },\n",
" \"Unit.name\": 1\n",
" },\n",
" \"$options\": {\"$rowlimit\": 10}\n",
"})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Parameter and ParameterSets"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Parameters are a flexible way to carry additional information, not being strictly pre-defined by the data model. Those parameters are name value pairs with an additional data type information, being grouped in parameter sets.\n",
"The following query returns the parameters belonging to certain MeaResult - including their parameter set information... "
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" ResultParameter.Name | \n",
" ResultParameter.Value | \n",
" ResultParameter.DataType | \n",
" ResultParameterSet.Name | \n",
" MeaResult.Id | \n",
"
\n",
" \n",
" \n",
" \n",
"
\n",
"
"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [ResultParameter.Name, ResultParameter.Value, ResultParameter.DataType, ResultParameterSet.Name, MeaResult.Id]\n",
"Index: []"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"ResultParameter\": {\"parameter_set.MeaResult.Name\": {\"$like\": \"Pend*\"}},\n",
" \"$attributes\": {\n",
" \"Name\": 1,\n",
" \"Value\": 1,\n",
" \"DataType\": 1,\n",
" \"parameter_set.Name\": 1,\n",
" \"parameter_set.MeaResult.Id\": 1\n",
" },\n",
" \"$options\": {\"$rowlimit\": 20}\n",
"})\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Given their flexible character, only minimal query capabilities can be offered for Parameters. Be aware that the conditions are combined by \"AND\" and lead to an empty result if you try to use multiple properties."
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" ResultParameter.Name | \n",
" ResultParameter.Value | \n",
" ResultParameter.DataType | \n",
" ResultParameterSet.Name | \n",
" MeaResult.Id | \n",
"
\n",
" \n",
" \n",
" \n",
"
\n",
"
"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [ResultParameter.Name, ResultParameter.Value, ResultParameter.DataType, ResultParameterSet.Name, MeaResult.Id]\n",
"Index: []"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"ResultParameter\": {\n",
" \"parameter_set.MeaResult.Name\": {\"$like\": \"Pend*\"},\n",
" \"Name\":\"start_time\",\n",
" \"DataType\":1,\n",
" \"Value\": {\"$like\": \"2023*\"}\n",
" },\n",
" \"$attributes\": {\n",
" \"Name\": 1,\n",
" \"Value\": 1,\n",
" \"DataType\": 1,\n",
" \"parameter_set.Name\": 1,\n",
" \"parameter_set.MeaResult.Id\": 1\n",
" },\n",
" \"$options\": {\"$rowlimit\": 20}\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" ResultParameter.Name | \n",
" ResultParameter.Value | \n",
" ResultParameter.DataType | \n",
" ResultParameterSet.Name | \n",
" MeaResult.Id | \n",
"
\n",
" \n",
" \n",
" \n",
"
\n",
"
"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [ResultParameter.Name, ResultParameter.Value, ResultParameter.DataType, ResultParameterSet.Name, MeaResult.Id]\n",
"Index: []"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"ResultParameter\": {\n",
" \"parameter_set.MeaResult.Name\": {\"$like\": \"Pend*\"},\n",
" \"$and\": [\n",
" {\n",
" \"Name\": \"start_time\",\n",
" \"DataType\": 1,\n",
" \"Value\": {\"$like\": \"2023*\"}\n",
" }\n",
" ]\n",
" },\n",
" \"$attributes\": {\n",
" \"Name\": 1,\n",
" \"Value\": 1,\n",
" \"DataType\": 1,\n",
" \"parameter_set.Name\": 1,\n",
" \"parameter_set.MeaResult.Id\": 1\n",
" },\n",
" \"$options\": {\"$rowlimit\": 20}\n",
"})\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Aggregates"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Distinct"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Test.Name | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" First Campaign | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Test.Name\n",
"0 First Campaign"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"Test\": {},\n",
" \"$attributes\": {\n",
" \"name\": {\"$distinct\": 1}\n",
" }\n",
"})\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lets do it adaptive with query condition"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Test.Name | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" First Campaign | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Test.Name\n",
"0 First Campaign"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"Test\": {\"name\": {\"$like\": \"*\"}},\n",
" \"$attributes\": {\n",
" \"name\": {\"$distinct\": 1}\n",
" }\n",
"})\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Min & Max"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" TestStep.DateCreated | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 19700101000000 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" TestStep.DateCreated\n",
"0 19700101000000"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"TestStep\": {},\n",
" \"$attributes\": {\n",
" \"DateCreated\": {\"$max\": 1}\n",
" }\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" TestStep.DateCreated | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 19700101000000 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" TestStep.DateCreated\n",
"0 19700101000000"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"TestStep\": {},\n",
" \"$attributes\": {\n",
" \"DateCreated\": {\"$min\": 1}\n",
" }\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" TestStep.DateCreated | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 19700101000000 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" TestStep.DateCreated\n",
"0 19700101000000"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"TestStep\": {},\n",
" \"$attributes\": {\n",
" \"DateCreated\": {\"$max\": 1, \"$min\": 1}\n",
" }\n",
"})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lets do it adaptive with query condition"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" TestStep.DateCreated | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 19700101000000 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" TestStep.DateCreated\n",
"0 19700101000000"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"con_i.query_data({\n",
" \"TestStep\": {\"Name\": {\"$like\": \"EngineNoise*\"}},\n",
" \"$attributes\": {\n",
" \"DateCreated\": {\"$max\": 1, \"$min\":1}\n",
" }\n",
"})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Close session\n",
"Don't forget to close the session to release the connection license. Otherwise the session will be auto closed after 30 minutes of inactivity."
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"con_i.logout()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## License\n",
"\n",
"Copyright © 2024 [Peak Solution GmbH](https://peak-solution.de)\n",
"\n",
"The training material in this repository is licensed under a Creative Commons BY-NC-SA 4.0 license. See [LICENSE](../LICENSE) file for more information."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
},
"vscode": {
"interpreter": {
"hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}