Add --db parameter support to CLI commands#304
Draft
himdel wants to merge 1 commit intoansible:develfrom
Draft
Conversation
Add --db parameter to both gather_automation_controller_billing_data and build_report commands to allow custom database connections via JSON configuration. When not provided, defaults to existing Django connection behavior for full backward compatibility. The implementation uses a configurable connection module (metrics_utility/db.py) that acts as a singleton, avoiding the need to pass connections through function parameters. All database usage updated to use get_connection() instead of importing django.db.connection directly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add a
--db=jsonparameter togather_automation_controller_billing_dataandbuild_reportcommands to allow custom database connections via JSON configuration.When not provided, defaults to existing Django connection as before.
When provided, it gets parsed as json, default values for
ENGINE,HOST&PORTare added,and it all gets passed to Django's
ConnectionHandler.The implementation uses a configurable singleton (
metrics_utility/db.py), configured by the commands,all previous usage of
django.db.connectionupdated to useget_connection()insteadExample:
uv run python manage.py gather_automation_controller_billing_data \ --db='{"NAME":"awx","USER":"admin","PASSWORD":"secret"}' \ --since=2024-01-01Assisted by Claude
wip test properly
see how far we are from dropping the awx dependency without breaking things