Skip to content

Commit

Permalink
fix spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
zainhoda committed Apr 12, 2024
1 parent 9eb52a2 commit b1e17a0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/vanna/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,13 +902,13 @@ def run_sql_mysql(sql: str) -> Union[pd.DataFrame, None]:
self.run_sql_is_set = True
self.run_sql = run_sql_mysql

def connect_to_oracle(
def connect_to_oracle(
self,
user: str = None,
password: str = None,
dsn: str = None,
):

"""
Connect to an Oracle db using oracledb package. This is just a helper function to set [`vn.run_sql`][vanna.base.base.VannaBase.run_sql]
**Example:**
Expand Down Expand Up @@ -953,23 +953,23 @@ def connect_to_oracle(
raise ImproperlyConfigured("Please set your Oracle db password")

conn = None

try:
conn = oracledb.connect(
user=user,
password=password,
dsn=dsn,
dsn=dsn,
)
except oracledb.Error as e:
raise ValidationError(e)

def run_sql_oracle(sql: str) -> Union[pd.DataFrame, None]:
if conn:
try:
sql = sql.rstrip()
sql = sql.rstrip()
if sql.endswith(';'): #fix for a known problem with Oracle db where an extra ; will cause an error.
sql = sql[:-1]
sql = sql[:-1]

cs = conn.cursor()
cs.execute(sql)
results = cs.fetchall()
Expand All @@ -981,7 +981,7 @@ def run_sql_oracle(sql: str) -> Union[pd.DataFrame, None]:
return df

except oracledb.Error as e:
conn.rollback()
conn.rollback()
raise ValidationError(e)

except Exception as e:
Expand Down

0 comments on commit b1e17a0

Please sign in to comment.