S-C-O-U-T / Pyadomd

A pythonic approach to query SSAS data models.
https://pyadomd.readthedocs.io/en/latest/index.html
Apache License 2.0
25 stars 6 forks source link

Support for ExecuteNonQuery please #23

Open NickSandelRWH opened 1 year ago

NickSandelRWH commented 1 year ago

Hello, when I try and execute an xmla command in my case to run a backup of a model I get the error:

The result set returned by the server is not a rowset.

The command worked fine but as it uses ExecuteReader as the only option for execute it expects a rowset returned. Is there support for ExecuteNonQuery (https://learn.microsoft.com/en-us/dotnet/api/microsoft.analysisservices.adomdclient.adomdcommand.executenonquery?view=analysisservices-dotnet#microsoft-analysisservices-adomdclient-adomdcommand-executenonquery) somewhere I haven't found yet or can it be added?

I did a brief hack of adding a method to see if it can work and this seems to work:

def executenonquery(self, query:str) -> Cursor:
    """
    Executes a non query against the data source, output is number of rows affected

    :params [query]: The query to be executed
    """
    self._cmd = AdomdCommand(query, self._conn)
    self._row_count = self._cmd.ExecuteNonQuery()      

    return self