Код: Выделить всё
class Products(Base):
__tablename__ = "products"
product_id = Column(Integer, primary_key = True)
name = Column(String, nullable= False)
price = Column(Integer, nullable= False)
description = Column(String)
stars = Column(Integer)
ingredients = Column(String, nullable= False)
nutrition = Column(String, nullable= False)
image_id = Column(Integer)
Код: Выделить всё
@classmethod
async def find_all(cls):
async with async_session_maker() as session:
query = select(cls.model)
result = await session.execute(query)
return result.mappings().all()
это
Подробнее здесь: https://stackoverflow.com/questions/792 ... s-of-table
Мобильная версия