python - 如何更新所有表并动态获取表名?
问题描述
我在 Tibco Spotfire 工作,想要一种方法来更新分析中的所有数据源。这可以使用此处描述的脚本来完成:Spotfire - 如何添加重新加载按钮
我已经这样实现了:
# * * *
#
# Update tables based on:
# https://stackoverflow.com/questions/49997755/spotfire-how-to-add-a-reload-button
#
# * * *
import ctypes
from System.Collections.Generic import List, Dictionary
from Spotfire.Dxp.Data import DataTable
from System.Collections import ArrayList
ctypes.windll.user32.MessageBoxW(0, "About to refresh all data from databases...", "Data Update", 1)
tables = ArrayList()
tables.Add(Document.Data.Tables["raw_table_col_detail"])
tables.Add(Document.Data.Tables["age_group"])
Document.Data.Tables.Refresh(tables)
ctypes.windll.user32.MessageBoxW(0, "Done with update.", "Data Update", 1)
我现在想实现它,以便它适用于任何分析。如何获取可用表的列表,然后遍历该列表(即如何动态地执行上述操作而无需指定表名、“raw_table_col_detail”、“age_group”等)。
解决方案
根据您使用的 Spotfire 版本,这里列出了几个选项https://community.tibco.com/wiki/how-refresh-or-reload-data-using-ironpython-script-tibco-点火
您可以遍历它们并一次刷新一个
import ctypes
ctypes.windll.user32.MessageBoxW(0, "About to refresh all data from databases...", "Data Update", 1)
for t in Document.Data.Tables:
t.Refresh()
ctypes.windll.user32.MessageBoxW(0, "Done with update.", "Data Update", 1)
或者您可以将它们推送到一个数组并一起刷新它们
import ctypes
from System.Collections import ArrayList
tables = ArrayList()
for t in Document.Data.Tables:
tables.Add(t)
ctypes.windll.user32.MessageBoxW(0, "About to refresh all data from databases...", "Data Update", 1)
Document.Data.Tables.Refresh(tables)
ctypes.windll.user32.MessageBoxW(0, "Done with update.", "Data Update", 1)
推荐阅读
- c++ - 如何将 C++ 项目从一个位置移动到另一个位置
- java - 如何告诉休眠验证器只验证一个注释?
- c# - 在控制台应用程序中跨项目访问的值
- r - R将布局对象的网格单位转换为本机
- python - 没有传递参数的 Lambda 函数
- azure - 液体模板转换在 Azure 逻辑应用中不起作用
- android - Gradle 构建在 Cloud Endpoints 的 generateClientLibs 处失败
- mysql - 如何使用 shell 脚本在 Amazon RDS MySql 数据库中运行 .SQL 文件
- excel - (VBA)如何删除重复的行并将相应的值求和到右列?
- flask - 解析一列的内容,并使用烧瓶和烧瓶迁移将结果插入另一列