第一种:
有场景会去查看数据库中当前索引,可通过以下语句查询:select last_value from related_result_id_seq;通过 execute().fetchall() 得到的结果 res , 需要取 res【0】【0】第二种:from sqlalchemy import funcsession.query(func.max(DB.TableName.id)).first()