Skip to content

Basic connection retargeting #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tableaudocumentapi/connection.py
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
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
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy