How can I connect to a local SSAS (OLAP) server from Python?

25 Views Asked by At

Currently, I am trying to establish a connection to a local SSAS (OLAP) server from Python. My ultimate goal is to be able to execute MDX queries. However, after many attempts with the following code, no matter how much I modify my connection string, I always receive this error message. I am not sure if the library itself can connect or if there is something wrong that I am doing.

You're welcome for your contributions.

Here is the error I am receiving

Erreur lors de la connexion à SSAS : (KeyError('Python string format error in connection string->'), 'Error opening connection to ""')

Here the code python

import pandas as pd
import adodbapi
import logging

data_source = "SERVER\\MOLAP"  
initial_catalog  = "bd_0001" 
user_id  = "DOMAINE\\COMPT1"  
password  = "YYYYY@123?$%"   


olap_conn_string = (
    f"Provider=MSOLAP.8;Data Source={data_source};Initial Catalog={initial_catalog};"
    f"User ID={user_id};Password={password}"
)

print(olap_conn_string)


def connexion_ssas():
        try:
    
            adodbapi.connect(olap_conn_string)
            print("OK - > Connexion ")
            logging.info("OK - > Connexion ")    

        except Exception as e:
            print(f"Erreur connexion à SSAS : {e}")
            logging.error(f"Erreur  connexion à SSAS : {e}")
0

There are 0 best solutions below