@@ -263,7 +263,7 @@ def upgrade(self, showprogress=True):
263263
264264 return message
265265
266- def executeStmt (self , query , custom_auth = None , env_vars = None ):
266+ def executeStmt (self , query , custom_auth = None , env_vars = None , ** kwargs ):
267267 """Executes a query using the StackQL instance and returns the output as a string.
268268 This is intended for operations which do not return a result set, for example a mutation
269269 operation such as an `INSERT` or a `DELETE` or life cycle method such as an `EXEC` operation
@@ -279,6 +279,12 @@ def executeStmt(self, query, custom_auth=None, env_vars=None):
279279 :type custom_auth: dict, optional
280280 :param env_vars: Command-specific environment variables for this execution.
281281 :type env_vars: dict, optional
282+ :param kwargs: Additional keyword arguments that override constructor parameters for this execution.
283+ Supported overrides: output, sep, header, auth, custom_registry, max_results, page_limit,
284+ max_depth, api_timeout, http_debug, proxy_host, proxy_port, proxy_user, proxy_password,
285+ proxy_scheme, backend_storage_mode, backend_file_storage_location, app_root,
286+ execution_concurrency_limit, dataflow_dependency_max, dataflow_components_max
287+ :type kwargs: optional
282288
283289 :return: The output result of the query in string format. If in `server_mode`, it
284290 returns a JSON string representation of the result.
@@ -292,25 +298,47 @@ def executeStmt(self, query, custom_auth=None, env_vars=None):
292298 >>> result
293299 """
294300 if self .server_mode :
301+ # Server mode: handle output override
302+ output_format = kwargs .get ('output' , self .output )
303+
295304 result = self .server_connection .execute_query (query , is_statement = True )
296305
297306 # Format result based on output type
298- if self . output == 'pandas' :
307+ if output_format == 'pandas' :
299308 import pandas as pd
300309 return pd .DataFrame (result )
301- elif self . output == 'csv' :
310+ elif output_format == 'csv' :
302311 # Return the string representation of the result
303312 return result [0 ]['message' ]
304313 else :
305314 return result
306315 else :
316+ # Local mode: handle parameter overrides
317+ override_params = None
318+ output_format = kwargs .get ('output' , self .output )
319+
320+ # If custom_auth is provided as kwarg, use it
321+ if 'auth' in kwargs :
322+ custom_auth = kwargs ['auth' ]
323+
324+ # Generate override params if kwargs provided
325+ if kwargs :
326+ from ..utils import generate_params_for_execution
327+ override_params = generate_params_for_execution (self ._base_kwargs , kwargs )
328+
307329 # Execute the query
308- result = self .local_query_executor .execute (query , custom_auth = custom_auth , env_vars = env_vars )
330+ result = self .local_query_executor .execute (query , custom_auth = custom_auth , env_vars = env_vars , override_params = override_params )
309331
310- # Format the result
311- return self .local_output_formatter .format_statement_result (result )
332+ # Format the result with appropriate output formatter
333+ if output_format != self .output :
334+ # Create a temporary formatter for this execution
335+ from .output import OutputFormatter
336+ temp_formatter = OutputFormatter (output_format )
337+ return temp_formatter .format_statement_result (result )
338+ else :
339+ return self .local_output_formatter .format_statement_result (result )
312340
313- def execute (self , query , suppress_errors = True , custom_auth = None , env_vars = None ):
341+ def execute (self , query , suppress_errors = True , custom_auth = None , env_vars = None , ** kwargs ):
314342 """
315343 Executes a StackQL query and returns the output based on the specified output format.
316344
@@ -325,6 +353,12 @@ def execute(self, query, suppress_errors=True, custom_auth=None, env_vars=None):
325353 :type custom_auth: dict, optional
326354 :param env_vars: Command-specific environment variables for this execution.
327355 :type env_vars: dict, optional
356+ :param kwargs: Additional keyword arguments that override constructor parameters for this execution.
357+ Supported overrides: output, sep, header, auth, custom_registry, max_results, page_limit,
358+ max_depth, api_timeout, http_debug, proxy_host, proxy_port, proxy_user, proxy_password,
359+ proxy_scheme, backend_storage_mode, backend_file_storage_location, app_root,
360+ execution_concurrency_limit, dataflow_dependency_max, dataflow_components_max
361+ :type kwargs: optional
328362
329363 :return: The output of the query, which can be a list of dictionary objects, a Pandas DataFrame,
330364 or a raw CSV string, depending on the configured output format.
@@ -344,29 +378,52 @@ def execute(self, query, suppress_errors=True, custom_auth=None, env_vars=None):
344378 >>> result = stackql.execute(query)
345379 """
346380 if self .server_mode :
381+ # Server mode: handle output override
382+ output_format = kwargs .get ('output' , self .output )
383+
347384 result = self .server_connection .execute_query (query )
348385
349386 # Format result based on output type
350- if self . output == 'pandas' :
387+ if output_format == 'pandas' :
351388 import pandas as pd
352389 import json
353390 from io import StringIO
354391 json_str = json .dumps (result )
355392 return pd .read_json (StringIO (json_str ))
356- elif self . output == 'csv' :
393+ elif output_format == 'csv' :
357394 raise ValueError ("CSV output is not supported in server_mode." )
358395 else : # Assume 'dict' output
359396 return result
360397 else :
398+ # Local mode: handle parameter overrides
399+ override_params = None
400+ output_format = kwargs .get ('output' , self .output )
401+ http_debug = kwargs .get ('http_debug' , self .http_debug )
402+
403+ # If custom_auth is provided as kwarg, use it
404+ if 'auth' in kwargs :
405+ custom_auth = kwargs ['auth' ]
406+
407+ # Generate override params if kwargs provided
408+ if kwargs :
409+ from ..utils import generate_params_for_execution
410+ override_params = generate_params_for_execution (self ._base_kwargs , kwargs )
411+
361412 # Apply HTTP debug setting
362- if self . http_debug :
413+ if http_debug :
363414 suppress_errors = False
364415
365416 # Execute the query
366- output = self .local_query_executor .execute (query , custom_auth = custom_auth , env_vars = env_vars )
417+ output = self .local_query_executor .execute (query , custom_auth = custom_auth , env_vars = env_vars , override_params = override_params )
367418
368- # Format the result
369- return self .local_output_formatter .format_query_result (output , suppress_errors )
419+ # Format the result with appropriate output formatter
420+ if output_format != self .output :
421+ # Create a temporary formatter for this execution
422+ from .output import OutputFormatter
423+ temp_formatter = OutputFormatter (output_format )
424+ return temp_formatter .format_query_result (output , suppress_errors )
425+ else :
426+ return self .local_output_formatter .format_query_result (output , suppress_errors )
370427
371428 async def executeQueriesAsync (self , queries ):
372429 """Executes multiple StackQL queries asynchronously using the current StackQL instance.
0 commit comments