Sql_alchemy_helper Engine fix (#3116)

* Added connect_args and options for creation of engine

* Added connect_args to profiler engine

* Error fixed on database_common profiler - isinstance error type or tuple of types
This commit is contained in:
Ayush Shah 2022-03-03 23:39:06 +05:30 committed by GitHub
parent 3d1c56511f
commit 84fd717c57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -41,7 +41,11 @@ class SQLAlchemyHelper:
"""
Create a SQLAlchemy connection to Database
"""
engine = create_engine(self.config.get_connection_url())
engine = create_engine(
self.config.get_connection_url(),
**self.config.options,
connect_args=self.config.connect_args
)
conn = engine.connect()
return conn

View File

@ -218,7 +218,11 @@ class DatabaseCommon(Database):
def __init__(self, config: SQLConnectionConfig):
self.config = config
self.connection_string = self.config.get_connection_url()
self.engine = create_engine(self.connection_string, **self.config.options)
self.engine = create_engine(
self.connection_string,
**self.config.options,
connect_args=self.config.connect_args,
)
self.connection = self.engine.raw_connection()
self.inspector = inspect(self.engine)
@ -236,19 +240,19 @@ class DatabaseCommon(Database):
def is_text(self, column_type: Type[types.TypeEngine]):
for sql_type in _text_types:
if isinstance(column_type, sql_type):
if isinstance(column_type, type(sql_type)):
return True
return False
def is_number(self, column_type: Type[types.TypeEngine]):
for sql_type in _numeric_types:
if isinstance(column_type, sql_type):
if isinstance(column_type, type(sql_type)):
return True
return False
def is_time(self, column_type: Type[types.TypeEngine]):
for sql_type in _time_types:
if isinstance(column_type, sql_type):
if isinstance(column_type, type(sql_type)):
return True
return False