mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Added a mechanism to detect a corrupt/broken config database file. Fixes #6460
This commit is contained in:
committed by
Akshay Joshi
parent
93ddc4a5ba
commit
7c88ee7cff
32
web/pgadmin/setup/db_table_check.py
Normal file
32
web/pgadmin/setup/db_table_check.py
Normal file
@@ -0,0 +1,32 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2021, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
from pgadmin.model import Version
|
||||
from pgadmin.model import db
|
||||
|
||||
|
||||
def get_db_table_names():
|
||||
db_table_names = db.metadata.tables.keys() if db.metadata.tables else 0
|
||||
return db_table_names
|
||||
|
||||
|
||||
def check_db_tables():
|
||||
is_error = False
|
||||
invalid_tb_names = list()
|
||||
db_table_names = get_db_table_names()
|
||||
# check table is actually present in the db.
|
||||
for table_name in db_table_names:
|
||||
if not db.engine.dialect.has_table(db.engine, table_name):
|
||||
invalid_tb_names.append(table_name)
|
||||
is_error = True
|
||||
|
||||
if is_error:
|
||||
return True, invalid_tb_names
|
||||
else:
|
||||
return False, invalid_tb_names
|
||||
Reference in New Issue
Block a user