0

I wrote this code to retrieve data from a cube:

rs = win32com.client.Dispatch('ADODB.RecordSet')
rs.__init__
conn = win32com.client.Dispatch('ADODB.Connection')
conn.__init__
conn.CommandTimeout=3000
conn.Open(connString)


#Retrieving data
try:
    rs.Open(mdxQuery, conn, 1, 3)
except Exception as e:
    print("An error occured while trying to retrieve data:")
    print(str(e))
    sys.exit(1)

try:
    t=rs.GetRows()
except Exception as ex:
    print(str(ex))

it seems the mdx query is ok, and retrieve some result (I can see it from debug mode) but when I try to assign the result of GetRows() function to a variable, it fails, with the following message:

ADODB.Field : Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

It seems to me GetRows() function is not able to handle NULL values. Is there a way to tell that method to skip NULL values or just fill it with blanks, and avoid this error?

Thanks

mStudent
  • 1,568
  • 3
  • 15
  • 21
  • You are using ADODB, which I believe is to run SQL. BUT, if you want to run MDX, you need something different. See whether this helps: https://stackoverflow.com/questions/2670887/ms-analysis-services-olap-api-for-python – Subbu Jul 19 '19 at 03:52
  • Thanks Subbu! I finally used Adomd from C#. It woks better, and allows to handle errors easily. – mStudent Jul 22 '19 at 11:55

0 Answers0