Skip to main content
4 Antworten
  1. 24. Nov. 2023, 13:07

    @Nupur Gupta​ 

    Hi, you have some options:

     

    Option 1:

    Publish the flow to Tableau Cloud/Server and run it manually from the flow page.

     

    Option 2:

    Run your flow locally in your computer using Tableau Prep Builder configuring the Output to a published data source.

     

    Option 3:

    You may create a hyper file from your flow using tableau prep builder command line and save the hyper file locally in your computer

    https://help.tableau.com/current/prep/en-us/prep_run_commandline.htm

     

    Then publish the hyper file using tableau server client. You may use a python code like (notice you will need to create a Personal Access Token: https://help.tableau.com/current/online/en-us/security_personal_access_tokens.htm)

    import tableauserverclient as TSC

    from pathlib import Path

    # server admin creds

    HOST="https://prod-useast-b.online.tableau.com"

    #Use the following to use User and password

    #USER="username"

    #PWRD="password"

    #When using PAT Sign in

    TOKENNAME="your_token_name"

    TOKENID="your_token_key-id"

    #Use "" to default site

    SITE="yoursiteurl"

    #Use "" to default project

    PROJECT_NAME="Your Project Name"

    ASYNC = True

    FILE = "yourhypernamefile.hyper"

    DSNAME ="Your Desired Published DS Name"

    server = TSC.Server(HOST, use_server_version=True)

    #Use the following to sign in with user and password

    #tableau_auth = TSC.TableauAuth(USER,PWRD,site=SITE)

    #Use the following for PAT

    tableau_auth = TSC.PersonalAccessTokenAuth(TOKENNAME, TOKENID, site_id=SITE)

    PATH_TO_FILE = Path(FILE)

    with server.auth.sign_in(tableau_auth):

    # Define publish mode - Overwrite, Append, or CreateNew

    publish_mode = TSC.Server.PublishMode.Overwrite

    # Get project_id from PROJECT_NAME

    all_projects, pagination_item = server.projects.get()

    for project in TSC.Pager(server.projects):

    if project.name == PROJECT_NAME:

    project_id = project.id

    new_conn_creds = None

    # Create the datasource object with the project_id

    datasource = TSC.DatasourceItem(project_id)

    new_datasource = TSC.DatasourceItem(project_id=project_id,name=DSNAME)

    print(f"Publishing {FILE} to {PROJECT_NAME}...")

    # Publish datasource

    if ASYNC:

    # Async publishing, returns a job_item

    new_job = server.datasources.publish(datasource, PATH_TO_FILE, publish_mode, connection_credentials=new_conn_creds, as_job=ASYNC)

    print("Datasource published asynchronously. Job ID: {0}".format(new_job.id))

    else:

    # Normal publishing, returns a datasource_item

    new_datasource = server.datasources.publish(datasource, PATH_TO_FILE, publish_mode,connection_credentials=new_conn_creds)

    print("Datasource published. Datasource ID: {0}".format(new_datasource.id))

    #Don't forget to sign out

    server.auth.sign_out()

    If this post resolves the question, would you be so kind to "Select as Best"?. This will help other users find the same answer/resolution and help community keep track of answered questions. Thank you.

     

    Regards,

     

    Diego Martinez

    Tableau Visionary and Forums Ambassador

0/9000