Skip to content

Commit 40e21ed

Browse files
Add full logs for failures (#147)
1 parent 28b9e2c commit 40e21ed

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

text_2_sql/data_dictionary/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ To generate a data dictionary, perform the following steps:
231231
**Execute the following commands in the `text_2_sql_core` directory:**
232232
2. Package and install the `text_2_sql_core` library. See [build](https://docs.astral.sh/uv/concepts/projects/build/) if you want to build as a wheel and install on an agent. Or you can run from within a `uv` environment and skip packaging.
233233
- Install the optional dependencies if you need a database connector other than TSQL. `uv sync --extra <DATABASE ENGINE>`
234-
3. Run `data_dictionary <DATABASE ENGINE>`
234+
3. Run `uv run data_dictionary <DATABASE ENGINE>`
235235
- You can pass the following command line arguements:
236236
- `-- output_directory` or `-o`: Optional directory that the script will write the output files to.
237237
- `-- single_file` or `-s`: Optional flag that writes all schemas to a single file.
@@ -244,4 +244,4 @@ To generate a data dictionary, perform the following steps:
244244

245245
> [!IMPORTANT]
246246
>
247-
> - The data dictioonary generation scripts will output column values for all possible filter clauses. This could lead to output of sensitive information. You should add exclusion criteria to exclude these for only columns that you may want to filter by.
247+
> - The data dictionary generation scripts will output column values for all possible filter clauses. This could lead to output of sensitive information. You should add exclusion criteria to exclude these for only columns that you may want to filter by.

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)