MCPcopy Create free account
hub / github.com/daniel2005d/mapXplore / run_query

Method run_query

middle/data_operation.py:193–219  ·  view source on GitHub ↗

Run the query and highlight the text that matches. Args: sentence (str): Run T-SQL query with relevant information value_to_hight_light (str): Text to hight light

(self, sentence:str, value_to_hight_light:str)

Source from the content-addressed store, hash-verified

191 AnsiPrint.printResult(result)
192
193 def run_query(self, sentence:str, value_to_hight_light:str):
194 """Run the query and highlight the text that matches.
195
196 Args:
197 sentence (str): Run T-SQL query with relevant information
198 value_to_hight_light (str): Text to hight light
199 """
200 result = self._cursor.execute_query(sentence)
201 information = Result()
202 if result is not None and len(result)>0:
203
204 for col in result[0].keys():
205 information.headers.append(col)
206
207 for row in result:
208 columns = []
209 formatted_columns = []
210 for key in row:
211 column_value = str(row[key])
212 column_formatted,_ = Color.highlight_text(column_value, value_to_hight_light) #self._format_b64_data(column_value, value_to_hight_light, key)
213 formatted_columns.append(column_formatted)
214 columns.append(column_value)
215
216 information.formatted_rows.append(formatted_columns)
217 information.rows.append(columns)
218
219 return information
220
221 def run(self, option:QueryType, value, hash_type:str=None) -> Result:
222 try:

Callers 1

_filter_by_valueMethod · 0.95

Calls 5

ResultClass · 0.90
keysMethod · 0.80
highlight_textMethod · 0.80
execute_queryMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected