trext.extract

The Extract package deals with creating, filling up and puslishing a .tde extract.

trext.extract.build

class trext.extract.build.ExtractBuilder[source]

Bases: object

Builds the tableau Extract by creating a Tableau Extract, defines the table skeleton, adds the table to the extract and fills this table with the relevant data for the TDE.

close()[source]
connect_to_db(view_or_table_name, conn_string, dbtype=None)[source]

Connect to the view or table that needs to be turned into a .tde extract

Parameters:
  • view_or_table_name – View or Table that needs to be an extract
  • conn_string – connection string to the database where the view or table exists
  • dbtype – type of db so the right pyodbc wrapper is used to connect
create_extract()[source]

Creates the extract by - connecting to the database, - building the tde path - initializing the extract - pulling data from db and filling the extract

Returns:path to the created .tde extract

trext.extract.exceptions

exception trext.extract.exceptions.NotExtractPathError[source]

Bases: exceptions.Exception

trext.extract.server

connection for tableau

class trext.extract.server.Tableau[source]

Bases: object

Tableau server connection class

close()[source]

Close connection to Tableau Server

connect(host, username, password, site_content_url='Default')[source]

Connect to the Tableau server

Parameters:
  • host – address of the Tableau server
  • username – Tableau Server username
  • password – Tableau Server password
  • site_content_url – Site to publish to
publish(tde_path, project_name='Default', datasource_name=None, overwrite=True)[source]

Publishes an extract to the Tableau Server

Parameters:
  • tde_path – path of tde to publish
  • project_name – name of project on the Tableau site to publish to
  • datasource_name – the name of the .tde to publish as
  • overwrite – boolean to flag if the .tde needs an overwrite when publishing

trext.extract.utils

trext.extract.utils.get_db_components(db_table_or_view)[source]

Splits the db_table into 3 components - db, schema and table/view

Parameters:db_table_or_view – of the form [DB].[SCHEMA].[TABLE]
Returns:tuple of db, schema and table
trext.extract.utils.get_extract_name(extract_path)[source]

Get the name of the extract in the format - name.tde

Parameters:extract_path – Path where the extract sits
Returns: