How to use the tableaudocumentapi.Datasource function in tableaudocumentapi

To help you get started, we’ve selected a few tableaudocumentapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tableau / document-api-python / test / test_datasource.py View on Github external
def setUp(self):
        self.ds = Datasource.from_file(TEST_TDS_FILE)
        self.to_delete = set()
github tableau / document-api-python / test / bvt.py View on Github external
def test_can_open_tdsx_and_save_changes(self):
        original_tdsx = Datasource.from_file(self.tdsx_file.name)
        original_tdsx.connections[0].server = 'newdb'
        original_tdsx.save()

        new_tdsx = Datasource.from_file(self.tdsx_file.name)
        self.assertEqual(new_tdsx.connections[
                         0].server, 'newdb')
github tableau / document-api-python / test / bvt.py View on Github external
def test_can_open_tdsx_and_save_as_changes(self):
        new_tdsx_filename = 'newtdsx.tdsx'
        original_wb = Datasource.from_file(self.tdsx_file.name)
        original_wb.connections[0].server = 'newdb'
        original_wb.save_as(new_tdsx_filename)

        new_wb = Datasource.from_file(new_tdsx_filename)
        self.assertEqual(new_wb.connections[
                         0].server, 'newdb')
        os.unlink(new_tdsx_filename)
github tableau / document-api-python / test / bvt.py View on Github external
def test_can_extract_datasource(self):
        wb = Workbook(self.workbook_file.name)
        self.assertEqual(len(wb.datasources), 1)
        self.assertIsInstance(wb.datasources[0], Datasource)
        self.assertEqual(wb.datasources[0].name,
                         'sqlserver.17u3bqc16tjtxn14e2hxh19tyvpo')
github tableau / document-api-python / test / bvt.py View on Github external
def test_can_extract_datasource(self):
        wb = Workbook(self.workbook_file.name)
        self.assertEqual(len(wb.datasources), 1)
        self.assertIsInstance(wb.datasources[0], Datasource)
        self.assertEqual(wb.datasources[0].name,
                         'sqlserver.17u3bqc16tjtxn14e2hxh19tyvpo')
github tableau / document-api-python / test / test_field.py View on Github external
def test_description_unicode(self):
        ds = Datasource.from_file(TEST_UNICODE_FILE)
        self.assertIsNotNone(ds.fields['A'].description)
github tableau / document-api-python / samples / list-tds-info / list_tds_info.py View on Github external
############################################################
# Step 1)  Use Datasource object from the Document API
############################################################
from tableaudocumentapi import Datasource

############################################################
# Step 2)  Open the .tds we want to replicate
############################################################
sourceTDS = Datasource.from_file('world.tds')

############################################################
# Step 3)  List out info from the TDS
############################################################
print('----------------------------------------------------------')
print('-- Info for our .tds:')
print('--   name:\t{0}'.format(sourceTDS.name))
print('--   version:\t{0}'.format(sourceTDS.version))
print('----------------------------------------------------------')
github tableau / document-api-python / Examples / GetFields / show_fields.py View on Github external
############################################################
# Step 1)  Use Datasource object from the Document API
############################################################
from tableaudocumentapi import Datasource

############################################################
# Step 2)  Open the .tds we want to inspect
############################################################
sourceTDS = Datasource.from_file('World.tds')

############################################################
# Step 3)  Print out all of the fields and what type they are
############################################################
print('----------------------------------------------------------')
print('--- {} total fields in this datasource'.format(len(sourceTDS.fields)))
print('----------------------------------------------------------')
for count, field in enumerate(sourceTDS.fields.values()):
    print('{:>4}: {} is a {}'.format(count+1, field.name, field.datatype))
    blank_line = False
    if field.calculation:
        print('      the formula is {}'.format(field.calculation))
        blank_line = True
    if field.default_aggregation:
        print('      the default aggregation is {}'.format(field.default_aggregation))
        blank_line = True