[Python] Flask-SQLAlchemy check if table exists in database

Discussão em 'Python' iniciado por Stack, Junho 27, 2025.

  1. Stack

    Stack Membro Participativo

    Flask-SQLAlchemy check if table exists in database. I see similar problems, but I try not to succeed.

    Flask-SQLAlchemy check if row exists in table

    I have create a table object ,like this:

    <class'flask_sqlalchemy.XXX'>,


    now how to check the object if exists in database.

    I do many try: eg:

    for t in db.metadata.sorted_tables:
    print("tablename",t.name)


    some table object is created before,but it doesnt exists in database,and now they. all print. eg:print content is

    tablename: table_1
    tablename: table_2
    tablename: table_3


    but only table_1 is exist datable,table_2 and table_3 is dynamica create,now I only want use the table_1.

    very thanks.

    Continue reading...

Compartilhe esta Página