diff --git a/src/rdbms-connect/HISTORY.rst b/src/rdbms-connect/HISTORY.rst index 482af3d10d1..e325342d697 100644 --- a/src/rdbms-connect/HISTORY.rst +++ b/src/rdbms-connect/HISTORY.rst @@ -3,6 +3,10 @@ Release History =============== +1.0.5 +++++++ ++ Use compatible release for `setproctitle` to support Python 3.11 + 1.0.4 ++++++ + Update mycli and pgcli versions diff --git a/src/rdbms-connect/azext_rdbms_connect/_params.py b/src/rdbms-connect/azext_rdbms_connect/_params.py index 343cb6b6797..ab0280d5722 100644 --- a/src/rdbms-connect/azext_rdbms_connect/_params.py +++ b/src/rdbms-connect/azext_rdbms_connect/_params.py @@ -13,15 +13,15 @@ def load_arguments(self, _): for command_group in ('mysql', 'postgres'): server_name_arg_type = CLIArgumentType(metavar='NAME', help="Name of the server. The name can contain only lowercase letters, numbers, and the hyphen (-) character. Minimum 3 characters and maximum 63 characters.", - local_context_attribute=LocalContextAttribute(name='server_name', actions=[LocalContextAction.SET, LocalContextAction.GET], scopes=['{} flexible-server'.format(command_group)])) + local_context_attribute=LocalContextAttribute(name='server_name', actions=[LocalContextAction.SET, LocalContextAction.GET], scopes=[f'{command_group} flexible-server'])) administrator_login_arg_type = CLIArgumentType(metavar='NAME', - local_context_attribute=LocalContextAttribute(name='administrator_login', actions=[LocalContextAction.GET, LocalContextAction.SET], scopes=['{} flexible-server'.format(command_group)])) + local_context_attribute=LocalContextAttribute(name='administrator_login', actions=[LocalContextAction.GET, LocalContextAction.SET], scopes=[f'{command_group} flexible-server'])) database_name_arg_type = CLIArgumentType(metavar='NAME', - local_context_attribute=LocalContextAttribute(name='database_name', actions=[LocalContextAction.GET, LocalContextAction.SET], scopes=['{} flexible-server'.format(command_group)])) + local_context_attribute=LocalContextAttribute(name='database_name', actions=[LocalContextAction.GET, LocalContextAction.SET], scopes=[f'{command_group} flexible-server'])) - with self.argument_context('{} flexible-server connect'.format(command_group)) as c: + with self.argument_context(f'{command_group} flexible-server connect') as c: c.argument('server_name', id_part=None, options_list=['--name', '-n'], arg_type=server_name_arg_type) c.argument('administrator_login', arg_group='Authentication', arg_type=administrator_login_arg_type, options_list=['--admin-user', '-u'], help='The login username of the administrator.') @@ -31,7 +31,7 @@ def load_arguments(self, _): c.argument('interactive_mode', options_list=['--interactive'], action='store_true', help='Pass this parameter to connect to database in interactive mode.') c.argument('querytext', options_list=['--querytext', '-q'], deprecate_info=c.deprecate(redirect='execute'), help='A query to run against the flexible server.') - with self.argument_context('{} flexible-server execute'.format(command_group)) as c: + with self.argument_context(f'{command_group} flexible-server execute') as c: c.argument('server_name', id_part=None, options_list=['--name', '-n'], arg_type=server_name_arg_type) c.argument('administrator_login', arg_group='Authentication', arg_type=administrator_login_arg_type, options_list=['--admin-user', '-u'], help='The login username of the administrator.') diff --git a/src/rdbms-connect/azext_rdbms_connect/custom.py b/src/rdbms-connect/azext_rdbms_connect/custom.py index 08f16e1d43d..5ef67df2545 100644 --- a/src/rdbms-connect/azext_rdbms_connect/custom.py +++ b/src/rdbms-connect/azext_rdbms_connect/custom.py @@ -81,7 +81,7 @@ def execute_flexible_server_postgres(cmd, server_name, administrator_login, admi def connect_to_server_helper(server_type, endpoint, default_db_name, server_name, administrator_login, administrator_login_password, database_name, query_command=None, interactive=None, file_path=None): - host = '{}{}'.format(server_name, endpoint) + host = f'{server_name}{endpoint}' json_data = None # setup or validate passed in params: @@ -155,13 +155,12 @@ def _connect_interactive(server_type, host, server_name, database_name, login_us set_environment_paths(EXTENSIONS_DIR) if server_type == "postgres": - cmd = "pgcli -h {0} -u {1} -W {2}".format(host, login_username, database_name) + cmd = f"pgcli -h {host} -u {login_username} -W {database_name}" else: - cmd = "mycli -h {0} -u {1} {2} --ssl-verify-server-cert".format(host, login_username, - database_name) + cmd = f"mycli -h {host} -u {login_username} {database_name} --ssl-verify-server-cert" os.system(cmd) except Exception as e: - raise AzureConnectionError("Unable to open interactive mode to {0}. Error: {1}".format(server_name, e)) + raise AzureConnectionError(f"Unable to open interactive mode to {server_name}. Error: {e}") def _connect_execute_query(server_type, host, server_name, database_name, login_username, login_pw, query=None): @@ -189,7 +188,7 @@ def _connect_execute_query(server_type, host, server_name, database_name, login_ except Exception as e: logger.warning("Failed connection to %s. Check error and validate firewall and public access " "or virtual network settings.", server_name) - raise AzureConnectionError("Unable to connect to flexible server: {}".format(e)) + raise AzureConnectionError(f"Unable to connect to flexible server: {e}") if query is not None: try: @@ -207,7 +206,7 @@ def _connect_execute_query(server_type, host, server_name, database_name, login_ for rv in result: json_data.append(dict(zip(row_headers, rv))) except Exception as e: - raise CLIError("Unable to execute query '{0}': {1}".format(query, e)) + raise CLIError(f"Unable to execute query '{query}': {e}") finally: try: cursor.close() @@ -244,7 +243,7 @@ def _connect_execute_file(server_type, host, server_name, database_name, login_u except Exception as e: logger.warning("Failed connection to %s. Check error and validate firewall and public access " "or virtual network settings.", server_name) - raise AzureConnectionError("Unable to connect to flexible server: {}".format(e)) + raise AzureConnectionError(f"Unable to connect to flexible server: {e}") # Execute the file fail_flag = False diff --git a/src/rdbms-connect/setup.py b/src/rdbms-connect/setup.py index 021eb7e499b..5af7cd25278 100644 --- a/src/rdbms-connect/setup.py +++ b/src/rdbms-connect/setup.py @@ -16,7 +16,7 @@ # TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. -VERSION = '1.0.4' +VERSION = '1.0.5' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers @@ -33,10 +33,10 @@ ] DEPENDENCIES = [ - 'setproctitle~=1.2.2', + 'setproctitle~=1.3.3', 'psycopg2==2.9.3', - 'mycli==1.26.1', - 'pgcli==3.4.1' + 'mycli~=1.27.0', + 'pgcli==4.0.1' ] with open('README.rst', 'r', encoding='utf-8') as f: