diff --git a/text_2_sql/data_dictionary/README.md b/text_2_sql/data_dictionary/README.md index 9660bd7..3251ba6 100644 --- a/text_2_sql/data_dictionary/README.md +++ b/text_2_sql/data_dictionary/README.md @@ -231,7 +231,7 @@ To generate a data dictionary, perform the following steps: **Execute the following commands in the `text_2_sql_core` directory:** 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. - Install the optional dependencies if you need a database connector other than TSQL. `uv sync --extra ` -3. Run `data_dictionary ` +3. Run `uv run data_dictionary ` - You can pass the following command line arguements: - `-- output_directory` or `-o`: Optional directory that the script will write the output files to. - `-- 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: > [!IMPORTANT] > -> - 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. +> - 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. diff --git a/text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/cli.py b/text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/cli.py index 9c858ae..01bb490 100644 --- a/text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/cli.py +++ b/text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/cli.py @@ -6,6 +6,7 @@ import typer from rich import print as rich_print from tenacity import RetryError +import traceback logging.basicConfig(level=logging.INFO) @@ -103,11 +104,13 @@ def create( rich_print(f"Database Engine {engine.value} is not supported.") raise typer.Exit(code=1) - except ImportError: + except Exception as e: + logging.error(e) detailed_error = f"""Failed to import { - engine.value} Data Dictionary Creator. Check you have installed the optional dependencies for this database engine.""" + engine.value} Data Dictionary Creator. Check you have installed the optional dependencies for this database engine and have configured all the environmental variables.""" rich_print("Text2SQL Data Dictionary Creator Failed ❌") rich_print(detailed_error) + rich_print(f"Error Messages: {traceback.format_exc()}") raise typer.Exit(code=1) @@ -120,6 +123,7 @@ def create( rich_print("Text2SQL Data Dictionary Creator Failed ❌") rich_print(f"Error Messages: {e}") + rich_print(traceback.format_exc()) raise typer.Exit(code=1) except Exception as e: @@ -127,7 +131,7 @@ def create( rich_print("Text2SQL Data Dictionary Creator Failed ❌") - rich_print(f"Error Messages: {e}") + rich_print(f"Error Messages: {traceback.format_exc()}") raise typer.Exit(code=1) else: diff --git a/text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/postgresql_data_dictionary_creator.py b/text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/postgresql_data_dictionary_creator.py index a99b56f..5d2c3fa 100644 --- a/text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/postgresql_data_dictionary_creator.py +++ b/text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/postgresql_data_dictionary_creator.py @@ -4,6 +4,7 @@ DataDictionaryCreator, EntityItem, ) +import asyncio import os from text_2_sql_core.utils.database import DatabaseEngine @@ -112,3 +113,8 @@ def extract_entity_relationships_sql_query(self) -> str: pg_attribute pk_col ON fk.confrelid = pk_col.attrelid AND fk.confkey[1] = pk_col.attnum ORDER BY "EntitySchema", "Entity", "ForeignEntitySchema", "ForeignEntity";""" + + +if __name__ == "__main__": + data_dictionary_creator = PostgresqlDataDictionaryCreator() + asyncio.run(data_dictionary_creator.create_data_dictionary())