trext.db
The db package deals with connecting to the Database, pulling the column metadata and the data
from the tables, and modifying the data to match the Tableau Type.
trext.db.conn
-
class
trext.db.conn.AnyDB(connection_string, dbtype=None)[source]
Bases: object
-
close()[source]
-
get_cursor()[source]
trext.db.consume
-
class
trext.db.consume.DBConsumer(cursor, view_or_table_name, dbtype)[source]
Bases: object
Pulls the view/table metadata and data from the database.
-
get_table_data()[source]
Generator that returns the data row by row of the view/table.
-
get_table_definition()[source]
Generator that returns the column name, type and the column position of the view/table.
| Returns: | column name, column position, column type |
trext.db.fill
Bases: object
Fills the extract skeleton with cleaned and formatted data.
Inserts the data row by row into the tableau extract skeleton
| Parameters: | db_data_row – row from the database |
trext.db.typemap
-
trext.db.typemap.get_type(db_type)[source]
Method to map the database column type to the Tableau SDK Type
| Parameters: | db_type – types that may have length in the declaration |
eg: CHAR(8)
:return: Tableau SDK Type if it exists
trext.db.utils
-
trext.db.utils.format_date(date_to_format)[source]
Formats the date value from database to the tableau format
| Parameters: | date_to_format – date value from db |
| Returns: | formatted date |
-
trext.db.utils.format_datetime(datetime_to_format)[source]
Formats the datetime value from database to the tableau format
| Parameters: | datetime_to_format – datetime value from db |
| Returns: | formatted datetime |
-
trext.db.utils.get_fake_date()[source]
-
trext.db.utils.get_fake_datetime()[source]