【问题标题】:Python Tableau API what is time() used for HourlyIntervalPython Tableau API 什么是 time() 用于 HourlyInterval
【发布时间】:2020-10-08 14:47:41
【问题描述】:

这是一个section of documentation,它展示了如何使用 tableau api 创建一个新的日程安排。 问题是它说一个新的时间表需要一个新的间隔,例如HourlyInterval 我不知道如何创建这个HourlyInterval。 这是文档中的一个示例:

import tableauserverclient as TSC
# sign in, etc.
 # Create an interval to run every 2 hours between 2:30AM and 11:00PM
        hourly_interval = TSC.HourlyInterval(start_time=time(2, 30),
                                             end_time=time(23, 0),
                                             interval_value=2)
 # Create schedule item
        hourly_schedule = TSC.ScheduleItem("Hourly-Schedule", 50, TSC.ScheduleItem.Type.Extract, TSC.ScheduleItem.ExecutionOrder.Parallel, hourly_interval)
 # Create schedule
        hourly_schedule = server.schedules.create(hourly_schedule)

当我使用这个例子时,我得到一个错误,时间没有定义

hourly_interval = TSC.HourlyInterval(start_time=time(2,30), end_time=time(23,0), interval_value=2)
NameError: name 'time' is not defined

我不知道我错过了什么,我认为我需要 import 'time' 但这似乎是完全不同的库。我还尝试以不同的方式分配start_timeend_time,但我得到了不同的错误,文档明确表示此API 需要这种格式:start_time=time(hour, minute)

【问题讨论】:

    标签: python time undefined tableau-api schedule


    【解决方案1】:

    只需添加:

    from datetime import time
    

    考虑查看示例,这是对文档 https://github.com/tableau/server-client-python/blob/master/samples/create_schedules.py 的一个很好的补充

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-30
      • 2012-09-08
      • 1970-01-01
      • 1970-01-01
      • 2023-01-11
      • 2011-11-12
      相关资源
      最近更新 更多