Sqlalchemy INSERT from SELECT
I have a problem's. INSERT from SELECT is compiled but not executed. There are no errors. Looking at the log file, you won't be SQL like ISERT INTO ... SELECT ... FROM ....
This is my code:
DBSession.query(ProductMediaGalleryArchive)\
.filter(ProductMediaGalleryArchive.product_id.in_(pack))\
.delete(synchronize_session=False)
query = DBSession.query(
ProductMediaGallery.code,
ProductMediaGallery.filename,
ProductMediaGallery.mimetype,
ProductMediaGallery.sha1hash,
ProductMediaGallery.position,
ProductMediaGallery.excluded,
ProductMediaGallery.created,
ProductMediaGallery.updated,
ProductMediaGallery.id,
ProductMediaGallery.is_rollover,
Product.code.label('product_code'),
).join((Product, Product.id==ProductMediaGallery.product_id))\
.filter(ProductMediaGallery.product_id.in_(pack))
insert(ProductMediaGalleryArchive).from_select(
(
ProductMediaGalleryArchive.code,
ProductMediaGalleryArchive.filename,
ProductMediaGalleryArchive.mimetype,
ProductMediaGalleryArchive.sha1hash,
ProductMediaGalleryArchive.position,
ProductMediaGalleryArchive.excluded,
ProductMediaGalleryArchive.created,
ProductMediaGalleryArchive.updated,
ProductMediaGalleryArchive.id,
ProductMediaGalleryArchive.is_rollover,
ProductMediaGalleryArchive.product_code
),
query
)
Does anyone know why it hasn't been executed?
+3
source to share