2 Replies Latest reply on Aug 24, 2018 3:35 PM by Cristian G

    TSC (Python): Publish Extract Data Source as a copy from another site

    Cristian G




      I am using Tableau Server v2018.1.2 in production and running a test server as a copy of production with a different domain name and with a proper license installed. We have a multi site server setup, with all of the sites essentially having the exact same projects, workbooks and data sources. The data sources are published as SQL Server extracts and the user/password differs amongst the various sites, but the SQL Server we connect to is the same.


      What I am trying to do, is to automate the creation of a new site and I am running into issues after having successfully published the data sources. These data sources are downloaded as extracts (.tdsx) from one of the sites ('Template') which we use as a repository of sorts for workbooks and data sources. I am using the Tableau Server Client python library.


      Here is a summary of the steps I am going through.


      01. Connect to Tableau (test) server as Server Administrator

      02. Use latest version of REST API v3.0 (for my 2018.1.2 server version) : use_server_version=True

      02. Create a new site

      03. Create our (standard) set of 7 projects

      04. Connect to Template site

      05. Download our (standards) set of 9 data sources (as .tdsx; include_extract=True)

      06. Connect back to the new site

      07. Get a list of all projects id's, save in a dict

      08. For each of the projects and based on a data source to project mapping I already have, create a ConectionCredentials object

      09. Set the user, password and embed=True

      10. Create a DatasourceItem object with the appropriate project id

      11. Publish each of the 9 data sources along with the connection credentials object



      The end result is that the data sources are created as Extracts and the time stamp is the time of creation. Everything seems to be just fine. However, when select (any) one of the data sources and run 'Refresh Extracts', I get an error 'Connection Failure'. But if I go to 'Edit Connection' on the same data source and run 'Test Connection' (using the Embedded password and without changing anything, I get 'Successfully connected to the server'.







      Here's the piece of code I use to publish the data sources.


      # Only projects for which there is one or more data sources
      for project in sorted(datasource_mapping.keys()):

         print "\nCreating datasource for project: {}".format(project)

         for datasource in datasource_mapping[project]:

         print "Datasource name: {}".format(datasource)

         # This is where the datasources from project 'Template' are downloaded to
         ds_path = datasource_dir + '\\' + datasource + '.tdsx'
         cc = TSC.ConnectionCredentials('Demo_Dbx', 'removed', embed=True)

        new_datasource = TSC.DatasourceItem(project_ids[project])

        new_datasource = server.datasources.publish(new_datasource, ds_path, 'CreateNew', connection_credentials=cc)




      And the pprint for one of the projects


      Creating datasource for project: Applications

      Datasource name: DS BI Applications


      {'_certification_note': None,

      '_certified': False,

      '_connections': None,

      '_content_url': 'DSBIApplications',

      '_created_at': datetime.datetime(2018, 8, 4, 4, 26, 42, tzinfo=<tableauserverclient.datetime_helpers.UTC object at 0x0000000002B0DA58>),

      '_datasource_type': 'sqlserver',

      '_id': '9093f3c1-c6f0-4f96-b243-a4335f449a0d',

      '_initial_tags': set([]),

      '_project_id': 'bb297aa7-b341-45d0-b4da-57d808baf430',

      '_project_name': 'Applications',

      '_updated_at': datetime.datetime(2018, 8, 4, 4, 26, 42, tzinfo=<tableauserverclient.datetime_helpers.UTC object at 0x0000000002B0DA58>),

      'name': 'DS BI Applications',

      'owner_id': 'ab732413-8d76-4374-878a-efec6fbd962e',

      'tags': set([])}



      I had extracted the same info from the data source on the Template project (the source of the .tdsx and has no issues with running the Extract), the data source object there looks the same as above, except for the time it was created at and project_id and owner_id.



      Prior to this I have used the Test sever first, then Production to recursively update some workbooks on existing sites, I have not encountered any issues in the process.



      I would appreciate any help you can give me.




        • 1. Re: TSC (Python): Publish Extract Data Source as a copy from another site
          Patrick Van Der Hyde

          Hello Cristian,


          I am moving this thread to the Server Administration area of the forums but I am also curious if you have submitted a ticket to support for this?  It will likely take the assistance of an engineer to review this with you for that connection issue. 



          • 2. Re: TSC (Python): Publish Extract Data Source as a copy from another site
            Cristian G

            Hi Patrick,


            I did work with support on this. In the meantime, I did some testing and noticed that my data source which is downloaded as a .tdsx and is of type Extract gets uploaded on the server as a .tde, thus the issue. When I use the Desktop and publish the exact same data source to the same project, it's an Extract. In my code I am forcing the use of latest REST api and I can see it's 3.0 which corresponds to my v2018.1.2 server version. I have since found a thread with other users having the same issue, while using tabcmd (I am using TSC/python) so I believe the issue is somewhere in the REST api, or something happened to the upgrade process on my server v10.1->v2018.1.2 and what I think I am using i.e. REST 3.0 in fact it's somehow not the case.


            At this stage, Level-1 support agreed it's an issue and will be looked at by Level-2 support.