Skip to content

Commit 8cf293d

Browse files
committed
Store warehouse and entity info
1 parent a9efb6a commit 8cf293d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

text_2_sql/data_dictionary/data_dictionary_creator.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ def __init__(
152152
self.entity_relationships = {}
153153
self.relationship_graph = nx.DiGraph()
154154

155+
self.warehouse = None
156+
self.database = None
157+
155158
load_dotenv(find_dotenv())
156159

157160
@property
@@ -321,6 +324,11 @@ async def extract_entities_with_descriptions(self) -> list[EntityItem]:
321324
if entity.entity not in self.excluded_entities
322325
]
323326

327+
# Add warehouse and database to entities
328+
for entity in all_entities:
329+
entity.warehouse = self.warehouse
330+
entity.database = self.database
331+
324332
return all_entities
325333

326334
async def extract_column_distinct_values(

text_2_sql/data_dictionary/sql_sever_data_dictionary_creator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the MIT License.
33
from data_dictionary_creator import DataDictionaryCreator, EntityItem
44
import asyncio
5+
import os
56

67

78
class SqlServerDataDictionaryCreator(DataDictionaryCreator):
@@ -24,7 +25,10 @@ def __init__(
2425
excluded_entities.extend(
2526
["dbo.BuildVersion", "dbo.ErrorLog", "sys.database_firewall_rules"]
2627
)
27-
return super().__init__(entities, excluded_entities, single_file)
28+
cls = super().__init__(entities, excluded_entities, single_file)
29+
cls.database = os.environ["Text2Sql__DatabaseName"]
30+
31+
return cls
2832

2933
"""A class to extract data dictionary information from a SQL Server database."""
3034

0 commit comments

Comments
 (0)