I want to create a temp table from a result of CTE using SQLAlchemy.
Tables definition:
class Data(Base):
__tablename__ = 'data'
c_id = Column(Integer, primary_key=True)
# ...
# temp table
class CIdTmp(Base):
__tablename__ = '#c_id_tmp'
c_id = Column(Integer, primary_key=True)
This is my CTE:
c_id_cte = (session.query(Data.c_id)).cte('c_id_cte')
I tried combining insert() with from_select() like this:
session.execute(CIdTmp.insert().from_select(['c_id'], c_id_cte))
But it produces this error:
AttributeError: type object 'CIdTmp' has no attribute 'insert'