Skip to content

Commit

Permalink
Oracle: update DSN construction to support special characters in user…
Browse files Browse the repository at this point in the history
…/password. (#4659)

* Update oracle.py

The reason I propose this change is to fix an issue when oracle password has an @
example of connection string: user/p@ssword@host

* Update oracle.py

Fixing init after comments

* Remove empty constructor.

Co-authored-by: Arik Fraimovich <arik@arikfr.com>
  • Loading branch information
juanvasquezreyes and arikfr authored Feb 27, 2020
1 parent 5fa5cd9 commit 5d533a3
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions redash/query_runner/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,6 @@ def configuration_schema(cls):
def type(cls):
return "oracle"

def __init__(self, configuration):
super(Oracle, self).__init__(configuration)

dsn = cx_Oracle.makedsn(
self.configuration["host"],
self.configuration["port"],
service_name=self.configuration["servicename"],
)

self.connection_string = "{}/{}@{}".format(
self.configuration["user"], self.configuration["password"], dsn
)

def _get_tables(self, schema):
query = """
SELECT
Expand Down Expand Up @@ -130,7 +117,12 @@ def output_handler(cls, cursor, name, default_type, length, precision, scale):
)

def run_query(self, query, user):
connection = cx_Oracle.connect(self.connection_string)
dsn = cx_Oracle.makedsn(
self.configuration["host"],
self.configuration["port"],
service_name=self.configuration["servicename"])

connection = cx_Oracle.connect(user=self.configuration["user"],password=self.configuration["password"], dsn=dsn)
connection.outputtypehandler = Oracle.output_handler

cursor = connection.cursor()
Expand Down

0 comments on commit 5d533a3

Please sign in to comment.