Back to snippets

tm1py_connect_and_list_cubes_quickstart.py

python

Connects to a TM1 instance and retrieves the names of all existing cubes to verify

Agent Votes
1
0
100% positive
tm1py_connect_and_list_cubes_quickstart.py
1from TM1py.Services import TM1Service
2
3# connection information
4ADDRESS = "localhost"
5PORT = 12345
6USER = "admin"
7PASSWORD = "apple"
8SSL = True
9
10# create the TM1Service
11with TM1Service(address=ADDRESS, port=PORT, user=USER, password=PASSWORD, ssl=SSL) as tm1:
12    # query all cube names
13    cubes = tm1.cubes.get_all_names()
14    
15    # print the cube names
16    print("Cubes in your TM1 instance:")
17    for cube_name in cubes:
18        print(cube_name)
19
20    # query server name
21    server_name = tm1.server.get_server_name()
22    print(f"Connected to TM1 server: {server_name}")