There is a method to push data into the datamodel, but i could not find any that can access it.
Please let me know if anymore details are needed.
Thank you
There is a method to push data into the datamodel, but i could not find any that can access it.
Please let me know if anymore details are needed.
Thank you
Note: sintax is the old pycelonis 1.0.
To get tables from the datamodel, something like this (dmtemp is a datamodel object):
from pycelonis.celonis_api.pql.pql import PQLColumn
from pycelonis.celonis_api.pql.pql import PQL, PQLFilter
query=PQL()
tablename=start_table_name
for c in dmtemp.tables.find(tablename).columns:
c_name=cm'name']
qval='"%s"."%s"' %(tablename,c_name)
column=PQLColumn(query=qval, name = c_name)
query.add(column)
df_final=dmtemp.get_data_frame(query)
To put data you need to update the table in the datamodel, then reload the datamodel
Something like:
pool.append_table(df_or_path=df_final,
table_name=hist_table_name,
connection=data_conection
)
(i think there is also an upsert function)
then reload datamodel:
dm.reload(wait_for_reload=True)
where dm is a datamodel object, got with something like:
dm=pool.datamodels.find(datamodel_name)
HTH. Happy 2023
Hi Guillermo,
Thank you for the explaination but my intention is to get the tables before they reach the datamodel in the datapool level.
To be exact, i need to get the tables from the ST and make some queries with 2 loops in ML and return it back to datapool for further processing in the datapool
So is there any way for that?
Thank you
Yes, you can run sql from python,
something like:
job_transformation_min=datajob.transformations.find(trans_job_Min_Notif_Rerouting_Start)
df_min=job_transformation_min.get_data_frame()
but the problem is that you will get only 100 records.
So the workaround is to load the tables into a temporary datamodel, then query them using PQL, and rewrite the result back
Note: sintax is the old pycelonis 1.0.
To get tables from the datamodel, something like this (dmtemp is a datamodel object):
from pycelonis.celonis_api.pql.pql import PQLColumn
from pycelonis.celonis_api.pql.pql import PQL, PQLFilter
query=PQL()
tablename=start_table_name
for c in dmtemp.tables.find(tablename).columns:
c_name=cm'name']
qval='"%s"."%s"' %(tablename,c_name)
column=PQLColumn(query=qval, name = c_name)
query.add(column)
df_final=dmtemp.get_data_frame(query)
To put data you need to update the table in the datamodel, then reload the datamodel
Something like:
pool.append_table(df_or_path=df_final,
table_name=hist_table_name,
connection=data_conection
)
(i think there is also an upsert function)
then reload datamodel:
dm.reload(wait_for_reload=True)
where dm is a datamodel object, got with something like:
dm=pool.datamodels.find(datamodel_name)
HTH. Happy 2023
Hi Guillermo.
Thank you. However in the current PyCelonis version all functions regarding "get_data_frame()" have been removed from PyCelonis. I am also looking for alternative ways to access data via Python.
Hi Guillermo.
Thank you. However in the current PyCelonis version all functions regarding "get_data_frame()" have been removed from PyCelonis. I am also looking for alternative ways to access data via Python.
Hello Max
In the last version, you need to use "data_model.export_data_frame(query)" .
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.