Skip to content

Commit 0d15f7f

Browse files
committed
Update the import error
1 parent 28b9e2c commit 0d15f7f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/cli.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import typer
77
from rich import print as rich_print
88
from tenacity import RetryError
9+
import traceback
910

1011
logging.basicConfig(level=logging.INFO)
1112

@@ -103,11 +104,13 @@ def create(
103104
rich_print(f"Database Engine {engine.value} is not supported.")
104105

105106
raise typer.Exit(code=1)
106-
except ImportError:
107+
except Exception as e:
108+
logging.error(e)
107109
detailed_error = f"""Failed to import {
108-
engine.value} Data Dictionary Creator. Check you have installed the optional dependencies for this database engine."""
110+
engine.value} Data Dictionary Creator. Check you have installed the optional dependencies for this database engine and have configured all the environmental variables."""
109111
rich_print("Text2SQL Data Dictionary Creator Failed ❌")
110112
rich_print(detailed_error)
113+
rich_print(f"Error Messages: {traceback.format_exc()}")
111114

112115
raise typer.Exit(code=1)
113116

@@ -120,14 +123,15 @@ def create(
120123
rich_print("Text2SQL Data Dictionary Creator Failed ❌")
121124

122125
rich_print(f"Error Messages: {e}")
126+
rich_print(traceback.format_exc())
123127

124128
raise typer.Exit(code=1)
125129
except Exception as e:
126130
logging.error(e)
127131

128132
rich_print("Text2SQL Data Dictionary Creator Failed ❌")
129133

130-
rich_print(f"Error Messages: {e}")
134+
rich_print(f"Error Messages: {traceback.format_exc()}")
131135

132136
raise typer.Exit(code=1)
133137
else:

text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/postgresql_data_dictionary_creator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
DataDictionaryCreator,
55
EntityItem,
66
)
7+
import asyncio
78
import os
89

910
from text_2_sql_core.utils.database import DatabaseEngine
@@ -112,3 +113,8 @@ def extract_entity_relationships_sql_query(self) -> str:
112113
pg_attribute pk_col ON fk.confrelid = pk_col.attrelid AND fk.confkey[1] = pk_col.attnum
113114
ORDER BY
114115
"EntitySchema", "Entity", "ForeignEntitySchema", "ForeignEntity";"""
116+
117+
118+
if __name__ == "__main__":
119+
data_dictionary_creator = PostgresqlDataDictionaryCreator()
120+
asyncio.run(data_dictionary_creator.create_data_dictionary())

0 commit comments

Comments
 (0)