MCPcopy
hub / github.com/tanelpoder/0xtools / get_available_columns

Method get_available_columns

xtop/core/query_engine.py:246–274  ·  view source on GitHub ↗

Get available columns for dynamic query. Executes the query with LIMIT 0 and DESCRIBE to get column info.

(self, params: QueryParams = None)

Source from the content-addressed store, hash-verified

244 return self.execute(query, params, debug, debug_profile)
245
246 def get_available_columns(self, params: QueryParams = None) -> List[str]:
247 """
248 Get available columns for dynamic query.
249 Executes the query with LIMIT 0 and DESCRIBE to get column info.
250 """
251 if params is None:
252 params = QueryParams()
253
254 # Prepare query with LIMIT 0
255 original_limit = params.limit
256 params.limit = 0
257 query = self.prepare_query(params)
258 params.limit = original_limit
259
260 # Remove any existing LIMIT clause and add LIMIT 0
261 import re
262 query = re.sub(r'\s+LIMIT\s+\d+\s*$', '', query, flags=re.IGNORECASE)
263 query = query.rstrip().rstrip(';')
264
265 # Use DESCRIBE to get column info
266 describe_query = f"DESCRIBE ({query} LIMIT 0)"
267
268 conn = self.data_source.connect()
269 try:
270 result = conn.execute(describe_query).fetchall()
271 return [row[0] for row in result]
272 except Exception as e:
273 print(f"Error getting columns: {e}", file=sys.stderr)
274 return []
275
276 def lookup_stack_trace(self, stack_hash: str, is_kernel: bool = True) -> Optional[str]:
277 """Look up a stack trace by its hash from kstacks/ustacks CSV"""

Callers

nothing calls this directly

Calls 5

prepare_queryMethod · 0.95
QueryParamsClass · 0.85
connectMethod · 0.80
fetchallMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected