[FEATURE] Add kwargs override support for execute and executeStmt methods #60
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements the ability to override constructor parameters on a per-execution basis for the
execute()andexecuteStmt()methods by accepting**kwargs. This allows users to change output formats, CSV formatting, authentication, and other parameters for individual queries without modifying the StackQL instance configuration.Problem
Previously, if you created a StackQL instance with a specific output format (e.g., CSV), you had to use that format for all queries or create a new instance. This was inconvenient when you needed different output formats for different queries in the same workflow.
Solution
Both
execute()andexecuteStmt()now accept keyword arguments that override constructor parameters for individual query executions:Changes Made
Core Implementation
execute()andexecuteStmt()methods to accept**kwargsgenerate_params_for_execution()helper function to merge base and override parametersQueryExecutor.execute()to acceptoverride_paramsparameter_base_kwargsin StackQL instance during initialization for dynamic parameter generationSupported Override Parameters
output: Output format ('dict', 'pandas', or 'csv')sep: CSV delimiter/separator (when output='csv')header: Include headers in CSV output (when output='csv')auth: Custom authentication for providerscustom_registry: Custom StackQL provider registry URLmax_results,page_limit,max_depth: Query execution limitsapi_timeout: API request timeouthttp_debug: Enable HTTP debug loggingproxy_host,proxy_port,proxy_user,proxy_password,proxy_schemebackend_storage_mode,backend_file_storage_location,app_rootexecution_concurrency_limit,dataflow_dependency_max,dataflow_components_maxFeatures
Testing
Created comprehensive test suite (
tests/test_kwargs_override.py) covering:execute()andexecuteStmt()methodsDocumentation
Added new "Overriding Parameters per Query" section to
docs/source/intro.rstwith:Backward Compatibility
This change is fully backward compatible. All existing code continues to work without modification, as the kwargs are optional parameters.
Closes #[issue_number]
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
releases.stackql.iopython -m pytest tests/test_output_formats.py::TestOutputFormats::test_dict_output_format -v(dns block)python -c from pystackql import StackQL; s = StackQL(output='csv'); print('Has _base_kwargs:', hasattr(s, '_base_kwargs')); print('Output:', s.output)(dns block)python /tmp/example_kwargs_override.py(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.