Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions text_2_sql/data_dictionary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <DATABASE ENGINE>`
3. Run `data_dictionary <DATABASE ENGINE>`
3. Run `uv run data_dictionary <DATABASE ENGINE>`
- 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.
Expand All @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import typer
from rich import print as rich_print
from tenacity import RetryError
import traceback

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -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)

Expand All @@ -120,14 +123,15 @@ 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:
logging.error(e)

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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
DataDictionaryCreator,
EntityItem,
)
import asyncio
import os

from text_2_sql_core.utils.database import DatabaseEngine
Expand Down Expand Up @@ -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())
Loading