-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rdbms-connect execute does not show output when using input from file (but it does using a direct query) #6359
Comments
Thank you for opening this issue, we will look into it. |
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ambhatna, @savjani. Issue DetailsDescribe the bugWhen running the command
Related commandaz mysql flexible-server execute ErrorsNAME -f /tmp/test.sql --database-name 'airsonic' Issue script & Debug outputcli.knack.cli: Command arguments: ['mysql', 'flexible-server', 'execute', '--admin-user', '', '--admin-password', '', '--name', 'airsdeleteme', '-f', '/tmp/test.sql', '--database-name', 'airsonic', '--debug'] Expected behaviorThe same result when using the --query option. It is already implemented there in line 201 # only print out if rows were returned
if cursor.description:
result = cursor.fetchmany(30) # limit to 30 rows of output for now
row_headers = [x[0] for x in cursor.description] # this will extract row headers
# format the result for a clean display
json_data = []
for rv in result:
json_data.append(dict(zip(row_headers, rv))) using the command
Environment Summaryazure-cli 2.49.0 core 2.49.0 Extensions: Dependencies: Python location '/opt/az/bin/python3' Python (Linux) 3.10.10 (main, May 19 2023, 08:20:31) [GCC 11.3.0] Legal docs and information: aka.ms/AzureCliLegal Your CLI is up-to-date. Additional contextNo response
|
Adding @mksuni to help with this |
Hi @jmservera, This is by design when executing from a script from a file to make it easier for automation scenarios with CLI. If there is any additional information you can provide that this is critical issue for you , please do share the details. This will help us evaluate based on your scenario. |
Thanks @mksuni . In my scenario, I was running a script like this one for MySQL: SET aad_auth_validate_oids_in_tenant = OFF;
DROP USER IF EXISTS 'myIdentity';
SELECT 'CREATING USER';
CREATE AADUSER 'myIdentity' IDENTIFIED BY '000-000-000';
SELECT 'GRANTING PRIVILEGES';
GRANT ALL PRIVILEGES ON airsonic.* TO 'myIdentity'@'%';
FLUSH privileges; This script does not work when using a direct query (I don't know completely why, but the CREATE USER fails when), but it does work when running it from a file. My problem is that when running it from a GitHub Action, if I want to check the logs to see what happened I don't get any output from the execution, just a failure or a success. Thanks, |
Describe the bug
When running the command
az mysql flexible-server execute
using the file input option-f query.sql
, it does not show the output of the query as it does when using the query option-q "SELECT 'HELLO WORLD'"
because the code that shows the output is not present in the_connect_execute_file
method:azure-cli-extensions/src/rdbms-connect/azext_rdbms_connect/custom.py
Line 256 in d16f533
Related command
az mysql flexible-server execute
Errors
NAME -f /tmp/test.sql --database-name 'airsonic'
Running sql file '/tmp/test.sql'...
Successfully executed the file.
Closed the connection to airsdeleteme
Issue script & Debug output
cli.knack.cli: Command arguments: ['mysql', 'flexible-server', 'execute', '--admin-user', '', '--admin-password', '', '--name', 'airsdeleteme', '-f', '/tmp/test.sql', '--database-name', 'airsonic', '--debug']
cli.knack.cli: init debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7faa3c90d480>, <function OutputProducer.on_global_arguments at 0x7faa3c8200d0>, <function CLIQuery.on_global_arguments at 0x7faa3c8512d0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'mysql': ['azure.cli.command_modules.rdbms', 'azext_rdbms_connect']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: rdbms 0.151 55 230
cli.azure.cli.core: Total (1) 0.151 55 230
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: rdbms-connect 0.373 4 4 /home/jmservera/.azure/cliextensions/rdbms-connect
cli.azure.cli.core: Total (1) 0.373 4 4
cli.azure.cli.core: Loaded 55 groups, 234 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : mysql flexible-server execute
cli.azure.cli.core: Command table: mysql flexible-server execute
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7faa3b6c6d40>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/jmservera/.azure/commands/2023-06-02.09-30-35.mysql_flexible-server_execute.1442.log'.
az_command_data_logger: command args: mysql flexible-server execute --admin-user {} --admin-password {} --name {} -f {} --database-name {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x7faa3b6e3880>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x7faa3b7417e0>, <function register_cache_arguments..add_cache_arguments at 0x7faa3b741900>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7faa3c820160>, <function CLIQuery.handle_query_parameter at 0x7faa3c851360>, <function register_ids_argument..parse_ids_arguments at 0x7faa3b741870>]
az_command_data_logger: extension name: rdbms-connect
az_command_data_logger: extension version: 1.0.4
cli.azext_rdbms_connect.custom: Running sql file '/tmp/test.sql'...
cli.azext_rdbms_connect.custom: Successfully executed the file.
cli.azext_rdbms_connect.custom: Closed the connection to airsdeleteme
cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x7faa3b70ad40>, <function _x509_from_base64_to_hex_transform at 0x7faa3b70add0>]
cli.knack.cli: Event: CommandInvoker.OnFilterResult []
cli.knack.cli: Event: Cli.SuccessfulExecute []
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7faa3b6c6f80>]
az_command_data_logger: exit code: 0
cli.main: Command ran in 2.438 seconds (init: 0.228, invoke: 2.210)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3552 in cache
telemetry.check: Negative: The /home/jmservera/.azure/telemetry.txt was modified at 2023-06-02 09:29:50, which in less than 600.000000 s
Expected behavior
The same result when using the --query option. It is already implemented there in line 201
using the command
az mysql flexible-server execute --admin-user $CURRENT_USERNAME --admin-password "$TOKEN" --name $MYSQL_SERVER_NAME -q "SELECT 'HELLO WORLD';" --database-name 'airsonic' -o table
shows:Environment Summary
azure-cli 2.49.0
core 2.49.0
telemetry 1.0.8
Extensions:
rdbms-connect 1.0.4
Dependencies:
msal 1.20.0
azure-mgmt-resource 22.0.0
Python location '/opt/az/bin/python3'
Extensions directory '/home/jmservera/.azure/cliextensions'
Python (Linux) 3.10.10 (main, May 19 2023, 08:20:31) [GCC 11.3.0]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.
Additional context
No response
The text was updated successfully, but these errors were encountered: