How can I check if a database is empty in SQLAlchemy?
I know you can do inspector.dialect.has_table(engine.connect(), 'table_name') to check for the existence of a single table, but I want to know if there are any tables at all in the database.
You can check tables in current database:
db.engine.table_names()
or after creating engine variable from connection string:
engine = sql.create_engine("connection_string")
sql.inspect(engine).get_table_names()
if db.engine.table_names() seems to work fine. Thanks!