in quick_start/utils.py [0:0]
def execute_command(cls, kusto_client: KustoClient, database_name: str, command: str) -> bool:
"""
Executes a Command using a premade client
:param kusto_client: Premade client to run Commands. can be either an adminClient or queryClient
:param database_name: DB name
:param command: The Command to execute
:return: True on success, false otherwise
"""
try:
if command.startswith(cls.MGMT_PREFIX):
client_request_properties = cls.create_client_request_properties("Python_SampleApp_ControlCommand")
else:
client_request_properties = cls.create_client_request_properties("Python_SampleApp_Query")
result = kusto_client.execute(database_name, command, client_request_properties)
print(f"Response from executed command '{command}':")
for row in result.primary_results[0]:
print(row.to_list())
return True
except KustoClientError as ex:
Utils.error_handler(f"Client error while trying to execute command '{command}' on database '{database_name}'", ex)
except KustoServiceError as ex:
Utils.error_handler(f"Server error while trying to execute command '{command}' on database '{database_name}'", ex)
except Exception as ex:
Utils.error_handler(f"Unknown error while trying to execute command '{command}' on database '{database_name}'", ex)
return False