Check whether sqlalchemy table is empty

前端 未结 2 1475
长发绾君心
长发绾君心 2021-01-13 05:12

I need to know whether any given sqlalchemy table (sqlalchemy.schema.Table) has exactly 0 rows. I have a lot of tables with a lot of rows in each and this has to run for al

2条回答
  •  一生所求
    2021-01-13 05:29

    You can use-

        db.query(Table_Name).first()
    

    where db is sessionmaker() object. Thanks @David S

提交回复
热议问题