I have a tm1py script to query log delta and load the result into a target cube. I got inspired by this sample
Code: Select all
TM1_MEASURE_LOG = ['User','TimeStamp','OldValue','NewValue']
with TM1Service(**config) as tm1:
cube_source = 'My Cube'
cube_target = '}Log_My Cube'
tm1.server.initialize_transaction_log_delta_requests(cube_source)
def get_transaction_log():
entries = tm1.server.execute_transaction_log_delta_request()
if len(entries) > 0:
cellset = dict()
for entry in entries:
if entry["StatusMessage"] is None:
for measure in TM1_MEASURE_LOG:
tuple_cellset = tuple(entry["Tuple"] + ["1"] + [measure])
cellset[tuple_cellset] = entry[measure]
cellset[tuple(entry["Tuple"] + ["Current Index"] + ["Current Index"])] = "1"
tm1.cubes.cells.write_values(cube_target, cellset)
i = 1
while True:
get_transaction_log()
time.sleep(4)
i = i + 1
if( i > 5):
break
Code: Select all
File ".../tm1transactionlog copy.py", line 48, in <module>
get_transaction_log()
File ".../tm1transactionlog copy.py", line 43, in get_transaction_log
[b]tm1.cubes.cells.write_values(cube_target, cellset)[/b]
File "...\TM1py\1.8.0\lib\TM1py\Services\CellService.py", line 109, in wrapper
return func(self, *args, **kwargs)
File "...\TM1py\1.8.0\lib\TM1py\Services\CellService.py", line 84, in wrapper
return func(self, *args, **kwargs)
File "...\TM1py\1.8.0\lib\TM1py\Services\CellService.py", line 749, in write_values
self._rest.POST(url=url, data=updates, **kwargs)
File "...\TM1py\1.8.0\lib\TM1py\Services\RestService.py", line 80, in wrapper
self.verify_response(response=response)
File "...\TM1py\1.8.0\lib\TM1py\Services\RestService.py", line 457, in verify_response
headers=response.headers)
[b]TM1py.Exceptions.Exceptions.TM1pyRestException: Text: '{"error":{"code":"278","message":"'}Views_}Log_My Cube' can not be found in collection of type 'Element'."}}' - Status Code: 404 - Reason: 'Not Found' - Headers: {'Content-Length': '124', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json; charset=utf-8', 'OData-Version': '4.0'}, 'Content-Encoding': 'gzip', 'Cache-Control': 'no-cache', 'Content-Type': 'application/json; charset=utf-8', 'OData-Version': '4.0'}[/b]