Jump to content
We've recently updated our Privacy Statement, available here. ×

Refresh data tables after executing a data function

Priyank Dwivedi

Recommended Posts

How can the user be absolutely sure that the 'data tables' will refresh after running a data function via an IronPython script? I noticed that even though the data function works as intended (saves some data to the tables in the SQL server), the refresh process in Spotfire is a hit or miss. Sometimes the data shows up and sometimes it doesn't.

Any advice on this?

My simple IronPython script:

from Spotfire.Dxp.Data.DataFunctions import DataFunctionExecutorService, DataFunctionInvocation, DataFunctionInvocationBuilderfrom System.Threading import Thread for fnc in Document.Data.DataFunctions: if fnc.Name == 'Overlays.Insert': #fnc.Execute() fnc.ExecuteSynchronously() print('Success') # Reload all data in a specific table Document.Data.Tables["Overlays"].ReloadAllData() #ReloadLinkedData() Document.Data.Tables["Forecast"].ReloadAllData() #ReloadLinkedData()
Link to comment
Share on other sites

Hi there!

Does the function return the data to Spotfire, or are the ReloadAllData() responsible for doing this? It looks like the ReloadAllData() operations return the data.

I suspect it's not a problem with Spotfire, but rather an async database issue. I would imagine that the commit may not yet have completed after INSERT and since you reload the data immediately, you may not get the committed rows, as they are not yet committed!

You could try adding a delay to allow the database to catch up.

You can also confirm if this is the issue by creating a separate script with just the ReloadAllData() operations. Then run each script sequentially manually. If you get the data you expect, then that will confirm the issue.

Andrew (TIBCO Spotfire Data Science)

Link to comment
Share on other sites

import timetime.sleep(1)

From: https://ironpython.net/documentation/dotnet/dotnet.html

Hopefully that will work! It will sleep for 1 second. Note that you can use core Python functions in IronPython. time is part of the Python/IronPython core. For future reference, you can't import or install additional Python packages into the IronPython engine in Spotfire.


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...