Skip to content

Commit e3dec1a

Browse files
committed
Update sql
1 parent 59ee8e3 commit e3dec1a

File tree

1 file changed

+25
-0
lines changed
  • text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors

1 file changed

+25
-0
lines changed

text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors/sql.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ def get_current_datetime(self) -> str:
3131
"""Get the current datetime."""
3232
return datetime.now().strftime("%d/%m/%Y, %H:%M:%S")
3333

34+
def get_current_date(self) -> str:
35+
"""Get the current date."""
36+
return datetime.now().strftime("%d/%m/%Y")
37+
38+
def get_current_time(self) -> str:
39+
"""Get the current time."""
40+
return datetime.now().strftime("%H:%M:%S")
41+
42+
def get_current_unix_timestamp(self) -> int:
43+
"""Get the current unix timestamp."""
44+
return int(datetime.now().timestamp())
45+
3446
@abstractmethod
3547
async def query_execution(
3648
self,
@@ -136,6 +148,19 @@ async def fetch_queries_from_cache(
136148
if parameters is None:
137149
parameters = {}
138150

151+
# Populate the parameters
152+
if "date" not in parameters:
153+
parameters["date"] = self.get_current_date()
154+
155+
if "time" not in parameters:
156+
parameters["time"] = self.get_current_time()
157+
158+
if "datetime" not in parameters:
159+
parameters["datetime"] = self.get_current_datetime()
160+
161+
if "unix_timestamp" not in parameters:
162+
parameters["unix_timestamp"] = self.get_current_unix_timestamp()
163+
139164
cached_schemas = await self.ai_search_connector.run_ai_search_query(
140165
question,
141166
["QuestionEmbedding"],

0 commit comments

Comments
 (0)