2021-06-08 09:11:47 -05:00
|
|
|
##########################################################################
|
|
|
|
#
|
|
|
|
# pgAdmin 4 - PostgreSQL Tools
|
|
|
|
#
|
2024-01-01 02:43:48 -06:00
|
|
|
# Copyright (C) 2013 - 2024, The pgAdmin Development Team
|
2021-06-08 09:11:47 -05:00
|
|
|
# This software is released under the PostgreSQL Licence
|
|
|
|
#
|
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
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:
|
2021-07-19 03:31:45 -05:00
|
|
|
try:
|
|
|
|
if not db.inspect(db.engine).has_table(table_name=table_name):
|
|
|
|
invalid_tb_names.append(table_name)
|
|
|
|
is_error = True
|
|
|
|
except AttributeError:
|
|
|
|
if not db.engine.dialect.has_table(db.engine, table_name):
|
|
|
|
invalid_tb_names.append(table_name)
|
|
|
|
is_error = True
|
2021-06-08 09:11:47 -05:00
|
|
|
|
|
|
|
if is_error:
|
|
|
|
return True, invalid_tb_names
|
|
|
|
else:
|
|
|
|
return False, invalid_tb_names
|