class trext.api.Extract(is_temp=True)[source]

Bases: object

A Tableau Extract.

Provides the endpoint to create and/or publish .tde extracts. Usage:

Create an extract >>> import trext >>> tde = trext.Extract() >>> connection_string = “appropriate db connection string” >>> tde.create(“db.schema.table”, conn_string=connection_string) Created! >>> tde.location /temp/extract.tde

Publish to Tableau Server (overwrites existing extract)

>>> tableau_auth_details = ("username", "password")
>>> publish_details = ("site_content_url", "project_name")
>>> tde.publish("tableau server address", auth=tableau_auth_details, params=publish_details)

Clean up after create and/or publish >>> tde.close()


Clean up on exit. Delete the extract only if temporary flag is True

Returns:if it is not a temporary extract
create(view_or_table_name, conn_string, dbtype=None)[source]

Method to create an extract based on a view or a table on a database

  • view_or_table_name – view or table to create an extract from
  • conn_string – connection string to the database
  • dbtype – type of database to connect to

Created! or Failed! message on creation

Returns:location of the .tde file if it was created or set up
publish(host_address, auth, params)[source]

Publish to Tableau Server (overwrites existing extract)

  • host_address – Address of the Tableau server to publish to
  • auth – a tuple of username and password for authentication
  • params – currently a typle of two parameters: site to publish to and project name

Message on completing publishing