This commit is contained in:
Laurent Indermuehle 2024-11-18 11:48:20 +01:00
parent 1d56f80976
commit e40ff32d3d
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09

View file

@ -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 []