From be74e276611fe2a4c0c547af09f28c7fe6ab02fb Mon Sep 17 00:00:00 2001 From: kevinglinski Date: Tue, 24 Apr 2018 20:22:48 -0400 Subject: [PATCH 1/2] adding oracle param support related to #137 --- tableaudocumentapi/connection.py | 46 +++++++++++++++++++++++++++++++- test/bvt.py | 7 +++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/tableaudocumentapi/connection.py b/tableaudocumentapi/connection.py index 30343b5..b851abd 100644 --- a/tableaudocumentapi/connection.py +++ b/tableaudocumentapi/connection.py @@ -16,6 +16,8 @@ def __init__(self, connxml): self._server = connxml.get('server') self._username = connxml.get('username') self._authentication = connxml.get('authentication') + self._schema = connxml.get('schema') + self._service = connxml.get('service') self._class = connxml.get('class') self._port = connxml.get('port', None) self._query_band = connxml.get('query-band-spec', None) @@ -26,7 +28,7 @@ def __repr__(self): @classmethod def from_attributes(cls, server, dbname, username, dbclass, port=None, query_band=None, - initial_sql=None, authentication=''): + initial_sql=None, authentication='', schema='', service=''): """Creates a new connection that can be added into a Data Source. defaults to `''` which will be treated as 'prompt' by Tableau.""" @@ -35,6 +37,8 @@ def from_attributes(cls, server, dbname, username, dbclass, port=None, query_ban xml.server = server xml.dbname = dbname xml.username = username + xml.schema = schema + xml.service = service xml.dbclass = dbclass xml.port = port xml.query_band = query_band @@ -206,3 +210,43 @@ def initial_sql(self, value): pass else: self._connectionXML.set('one-time-sql', value) + + @property + def schema(self): + """Database schema for the connection. Not the table name.""" + return self._schema + + @schema.setter + def schema(self, value): + """ + Set the connection's schema property. + + Args: + value: New name of the database schema. String. + + Returns: + Nothing. + + """ + self._schema = value + self._connectionXML.set('schema', value) + + @property + def service(self): + """Database service for the connection. Not the table name.""" + return self._schema + + @service.setter + def service(self, value): + """ + Set the connection's service property. + + Args: + value: New name of the database service. String. + + Returns: + Nothing. + + """ + self._service = value + self._connectionXML.set('service', value) diff --git a/test/bvt.py b/test/bvt.py index b2fb4af..e4bdad8 100644 --- a/test/bvt.py +++ b/test/bvt.py @@ -112,6 +112,13 @@ def test_can_create_connection_from_scratch(self): self.assertEqual(conn.dbclass, 'mysql') self.assertEqual(conn.authentication, 'd') + def test_can_create_oracle_connection_from_scratch(self): + conn = Connection.from_attributes( + server='a', dbname='b', username='c', dbclass='oracle', schema='d', service='e') + self.assertEqual(conn.server, 'a') + self.assertEqual(conn.schema, 'd') + self.assertEqual(conn.service, 'e') + def test_can_create_datasource_from_connections(self): conn1 = Connection.from_attributes( server='a', dbname='b', username='c', dbclass='mysql', authentication='d') From fb3cd228efe2ef093ea73aaee995b525a11e4425 Mon Sep 17 00:00:00 2001 From: kevinglinski Date: Thu, 26 Apr 2018 10:38:14 -0400 Subject: [PATCH 2/2] fix copy paste error --- tableaudocumentapi/connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tableaudocumentapi/connection.py b/tableaudocumentapi/connection.py index b851abd..504983a 100644 --- a/tableaudocumentapi/connection.py +++ b/tableaudocumentapi/connection.py @@ -234,7 +234,7 @@ def schema(self, value): @property def service(self): """Database service for the connection. Not the table name.""" - return self._schema + return self._service @service.setter def service(self, value): 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