Моя модель:
Код: Выделить всё
class Product(Base):
__tablename__ = "products"
idf: Mapped[str] = mapped_column(primary_key=True, unique=True)
name: Mapped[str] = mapped_column(nullable=False)
article: Mapped[str] = mapped_column(nullable=False, unique=True)
category: Mapped[str] = mapped_column(default="")
description: Mapped[str] = mapped_column(default="")
Код: Выделить всё
async def import(self, db: AsyncSession, objects):
await db.run_sync(lambda session: session.bulk_save_objects(objects))
await db.commit()
return {"status": "Import has been finished"}
Подробнее здесь: https://stackoverflow.com/questions/790 ... postgresql
Мобильная версия