diff --git a/plugins/modules/mysql_info.py b/plugins/modules/mysql_info.py index 70c2ade..c6f88f7 100644 --- a/plugins/modules/mysql_info.py +++ b/plugins/modules/mysql_info.py @@ -662,10 +662,10 @@ class MySQL_Info(object): def __get_databases(self, exclude_fields, return_empty_dbs): """Get info about databases.""" - + def is_field_included(field_name): return not exclude_fields or f'db_{field_name}' not in exclude_fields - + def create_db_info(db_data): info = {} if is_field_included('size'): @@ -680,14 +680,14 @@ class MySQL_Info(object): query_parts.append('SUM(data_length + index_length) AS "size"') if is_field_included('table_count'): query_parts.append('COUNT(table_name) as "tables"') - + query = f"{', '.join(query_parts)} FROM information_schema.TABLES GROUP BY table_schema" - + # Get and process databases with tables databases = self.__exec_sql(query) or [] for db in databases: self.info['databases'][db['name']] = create_db_info(db) - + # Handle empty databases if requested if return_empty_dbs: empty_databases = self.__exec_sql('SHOW DATABASES') or []