FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Basic connection retargeting by t8y8 · Pull Request #65 · tableau/document-api-python · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 10 additions & 0 deletions tableaudocumentapi/connection.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Connection - A class for writing connections to Tableau files
#
###############################################################################
from tableaudocumentapi.dbclass import is_valid_dbclass


class Connection(object):
Expand Down Expand Up @@ -111,3 +112,12 @@ def authentication(self):
@property
def dbclass(self):
return self._class

@dbclass.setter
def dbclass(self, value):

if not is_valid_dbclass(value):
raise AttributeError("'{}' is not a valid database type".format(value))

self._class = value
self._connectionXML.set('dbclass', value)
60 changes: 60 additions & 0 deletions tableaudocumentapi/dbclass.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@


KNOWN_DB_CLASSES = ('msaccess',
'msolap',
'bigquery',
'asterncluster',
'bigsql',
'aurora',
'awshadoophive',
'dataengine',
'DataStax',
'db2',
'essbase',
'exasolution',
'excel',
'excel-direct',
'excel-reader',
'firebird',
'powerpivot',
'genericodbc',
'google-analytics',
'googlecloudsql',
'google-sheets',
'greenplum',
'saphana',
'hadoophive',
'hortonworkshadoophive',
'maprhadoophive',
'marklogic',
'memsql',
'mysql',
'netezza',
'oracle',
'paraccel',
'postgres',
'progressopenedge',
'redshift',
'snowflake',
'spark',
'splunk',
'kognitio',
'sqlserver',
'salesforce',
'sapbw',
'sybasease',
'sybaseiq',
'tbio',
'teradata',
'vectorwise',
'vertica',
'denormalized-cube',
'csv',
'textscan',
'webdata',
'webdata-direct',
'cubeextract')


def is_valid_dbclass(dbclass):
return dbclass in KNOWN_DB_CLASSES
7 changes: 7 additions & 0 deletions test/bvt.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ def test_can_write_attributes_to_connection(self):
self.assertEqual(conn.username, 'bob')
self.assertEqual(conn.server, 'mssql2014.test.tsi.lan')

def test_bad_dbclass_rasies_attribute_error(self):
conn = Connection(self.connection)
conn.dbclass = 'sqlserver'
self.assertEqual(conn.dbclass, 'sqlserver')
with self.assertRaises(AttributeError):
conn.dbclass = 'NotReal'


class DatasourceModelTests(unittest.TestCase):

Expand Down

Back | FazBrowse Home | New Git URL