Skip to content

Commit

Permalink
add more logging around connection attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-cartwright committed Jul 29, 2024
1 parent ec3963b commit aee40e0
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions metadata-ingestion/src/datahub/ingestion/source/sql/sql_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,25 +391,30 @@ def error(self, log: logging.Logger, key: str, reason: str) -> None:
self.report.report_failure(key, reason[:100])
log.error(f"{key} => {reason}\n{traceback.format_exc()}")

def get_inspectors(self) -> Iterable[Inspector]:
# This method can be overridden in the case that you want to dynamically
# run on multiple databases.
try:
url = self.config.get_sql_alchemy_url()
logger.debug(f"SQLAlchemy URL constructed: {url}")

# Create engine
engine = create_engine(url, **self.config.options)
logger.debug("SQLAlchemy engine created successfully")
def get_inspectors(self) -> Iterable[Inspector]:
# This method can be overridden in the case that you want to dynamically
# run on multiple databases.
try:
url = self.config.get_sql_alchemy_url()
logger.debug(f"SQLAlchemy URL constructed: {url}")

# Create engine
engine = create_engine(url, **self.config.options)
logger.debug("SQLAlchemy engine created successfully")

try:
with engine.connect() as conn:
logger.debug(f"Successfully connected to database using URL: {url}")
inspector = inspect(conn)
logger.debug("Inspector object created")
yield inspector
except Exception as e:
logger.error(f"Error in get_inspectors: {e}")
except Exception as conn_e:
logger.error(f"Error during connection or inspection: {conn_e}")
raise
except Exception as e:
logger.error(f"Error in get_inspectors: {e}")
raise

def get_db_name(self, inspector: Inspector) -> str:
engine = inspector.engine
Expand Down

0 comments on commit aee40e0

Please sign in to comment.