Pyton Celonis API : Creating a new datamodel in 4.5 not connecting


Hello Everyone,

I am trying to connect data model in Celonis 4.5 from Python and trying to import tables.
Execution is failing while creating data model.

Error From Python-
Traceback (most recent call last):

File “C:\Users<User_Name>\AppData\Local\Continuum\anaconda3\lib\site-packages\celonis_tools\model\”, line 2191, in create_new
return super(DBConnection, cls).create_new(parent, **data)

File “C:\Users<User_Name>\AppData\Local\Continuum\anaconda3\lib\site-packages\celonis_tools\model\”, line 360, in create_new
return obj.create()

File “C:\Users<User_Name>\AppData\Local\Continuum\anaconda3\lib\site-packages\celonis_tools\model\”, line 230, in create
ret =*args, params=kw, **

File “C:\Users<User_Name>\AppData\Local\Continuum\anaconda3\lib\site-packages\celonis_tools\”, line 108, in post
ret =, params=params, json=kw or None)

File “C:\Users<User_Name>\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\”, line 555, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)

File “C:\Users<User_Name>\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\”, line 508, in request
resp = self.send(prep, **send_kwargs)

File “C:\Users<User_Name>\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\”, line 625, in send
r = dispatch_hook(‘response’, hooks, r, **kwargs)

File “C:\Users<User_Name>\AppData\Local\Continuum\anaconda3\lib\site-packages\requests\”, line 31, in dispatch_hook
_hook_data = hook(hook_data, **kwargs)

File “C:\Users<User_Name>\AppData\Local\Continuum\anaconda3\lib\site-packages\celonis_tools\”, line 232, in parse_result
raise CelonisRequestError®

CelonisRequestError: 400 Client Error: Bad Request for url

Code I implemented in Python:
Establishing connection with Celonis with API token:
conn = DBConnection.create_new(dm,"<Database_name>","",
“”,", “”,, “jdbc:sap”)
t = dm.import_table(conn, “<table_name>”)

From Document:
conn = DBConnection.create_new(dm, “My Connection”, “mssql”, “localhost”, “user”,
˓→"password", “test_db”, 1433, “dbo”)
t = dm.import_table(conn, “table_name”)

  1. Is there any parameter i am missing?
  2. Can we load multiple tables at a time?

Please assist on this.



Hello Parimala,

can you please describe how you setup your connection to Celonis in Python? You need to create a CelonisSession in python, according to

It seems like the CelonisSession is not created correctly.



Hello David,

I have set the connection as below:

with CelonisSession(“https://localhost:9000”, “your_username”, api_token=“your_token”, api_secret=“your_secret”) as session:
–write your code here –
conn = DBConnection.create_new(dm, “<Connection_Name>”, “HANA”, “<host_name>”, “<User_Name>”,"<_password>", “<Schema_Name>”, <-port>, “<driver_name> Ex: jdbc:sap”)
t = dm.import_table(conn, “table_name”)


Hello Parimala,

I just tried it, and for me, it works.
Does getting the datamodel work?:
dm = DataModel(42)
where 42 is your datamodel ID.

Did you enter the correct connection details in the CelonisSession (Host, Port, Username, API-Key, API-Token) and of your database you want to connect to? For HANA, you need to use “hana” (all lowercase) as the template specifier (third argument of DBConnection.create_new().



Hello David,

Yes Celonis session is working.

with CelonisSession(“https://localhost:9000”, “your_username”, api_token=“your_token”, api_secret=“your_secret”) as session:
dm = DataModel(161) # My data model number.

But I would like to know :
DBConnection.create_new () generic parameter list like
DBConnection.create_new (host_name,port_num,schema_name,…etc)
I couldn’t find in document in generic way.



the DBConnection.create_new takes the following parameters:

conn = DBConnection.create_new(DataModel, Name, Template, host, Username, Password, Database, Port, Schema)

  • DataModel: Your datamodel
  • Name: The name your DB connection should have
  • Template: The template identifier. Can be "hana", "hana ssl" or "hana ssl no validation" if you’d like to connect to a HANA
  • Host: the host name of the database
  • Username: The database user to use
  • Password: The password of the Database user
  • Database: The name of the Database to connect to
  • Port: The port to use (as an integer). For HANA, it should be 30015
  • Schema: The database schema name

You can then use t = dm.import_table(conn, “table_name”) to add the table with table_name to the datamodel.


Hello David,

Thanks for providing detailed generic information.
Following steps are performed so far:

  1. Created session with Celonis using API key.
  2. Connected to Data model from data model ID
  3. Established the connection to data model.
  4. Loaded a table using t = dm.import_table(conn, “<Test_Table>”) (Test Table is existed in Database).

I couldn’t see the tables in list of tables under DataSources>Import Data.
Screenshot :

I would like to understand what exactly this statement do ? dm.reload() as i understood after running this statement table data has to load. Could you please brief on this.

Parimala N


Hello Parimala,

this looks like either you specified the wrong schema name (check again if you spelled the schema name correctly), or the schema does not include any tables, or the Database user you are using doesn’t have the rights to access the schema or the tables.

Best regards


Hello David,

When i try to create manually with same details I am able to see connections and relevant tables.
Same when using Python facing issue :
Connection Status from Celonis ( via Python). Data source is getting connected below is screenshot reference.

Table List Error: (Empty List)

My Code:

Code_datasource_connection.txt (464 Bytes)



can you please check if all the credentials are correct in Celonis? So click on the “edit” button of the connection you created in python and check if everything is correct, especially the connection string. Also compare all credentials to the working connection you created in Celonis.

I currently have no idea why it is not working.



Hello David,

I have checked the credentials too , all are correct. Connection strings are below like this:



thanks for checking! Unfortunately, I cannot tell what the problem is just based on the given information.
Could you please write a ticket to our servicedesk ( )? Then we have the possibility to investigate your problem further.

Thanks for your patience!


something that I learned the hard way is that schema names are case sensitive. Is this something you checked @parimala?


Yes i checked too everything is as it is. But now its showing list of tables under Tables in Database nothing has changed in my code much regarding DB parameters. ( Initially i tested 4.5 beta version may be now our server upgraded to official version of 4.5, that might be the only change i can see :wink:

My next task is to import the all listed tables through python.

1 Like


after creating the connection, you can get the table names using
table_names = conn.get_table_names()

You can then loop through the list of table names and add them to your data model:
for table_name in table_names:
dm.import_table(conn, table_name)

In order to get the data in your datamodel, you need to reload it:



Yeah David it worked. Thanks for support.
But initially when data source is loading I could see all list of tables from my schema and there are almost 10-15 tables.

When it comes to status is see only one table loads.


You only need to reload the datamodel once, so execute dm.reload() only once after the loop in which you add the tables to the datamodel.
Then it should load all the tables at once.


Yes i am doing once.
conn = <_Data source connection>
table_names = conn.get_table_names()
for table_name in table_names:
dm.import_table(conn, table_name)