Exemplo n.º 1
0
    def test_can_create_datasource_from_connections(self):
        conn1 = Connection.from_attributes(
            server='a', dbname='b', username='******', dbclass='mysql', authentication='d')
        conn2 = Connection.from_attributes(
            server='1', dbname='2', username='******', dbclass='mysql', port='1337', authentication='7')
        ds = Datasource.from_connections('test', connections=[conn1, conn2])

        self.assertEqual(ds.connections[0].server, 'a')
        self.assertEqual(ds.connections[0].port, None)
        self.assertEqual(ds.connections[1].server, '1')
        self.assertEqual(ds.connections[1].port, '1337')
Exemplo n.º 2
0
    def test_can_create_datasource_from_connections(self):
        conn1 = Connection.from_attributes(server='a',
                                           dbname='b',
                                           username='******',
                                           dbclass='mysql',
                                           authentication='d')
        conn2 = Connection.from_attributes(server='1',
                                           dbname='2',
                                           username='******',
                                           dbclass='mysql',
                                           authentication='7')
        ds = Datasource.from_connections('test', connections=[conn1, conn2])

        self.assertEqual(ds.connections[0].server, 'a')
        self.assertEqual(ds.connections[1].server, '1')
Exemplo n.º 3
0
from tableaudocumentapi import Datasource
from tableaudocumentapi import Field
from tableaudocumentapi import Connection

sourceWB = Workbook('TestCase4.twbx')

db = ""
sourceDB = ""
count = 1

#Importing Datasource object from the workbook
for j in sourceWB.datasources:
    print "Datasource " + str(count)
    for x in j.connections:
        db = x.dbclass
    sourceDB = Datasource.from_connections(db, j.connections)

    #Printing information about the datasource
    print "Connection information :"
    print sourceDB.connections
    print ""
    print "Datasource caption :"
    print sourceDB.caption
    print ""
    print "Tableau version :"
    print sourceDB.version
    print ""
    sourceDB.caption = "abc"
    print sourceDB.caption

    #Datasource.save (sourceDB)