Can I create a temporary table in SQLAlchemy without adding to Table._prefixes?

I want to create a temporary table in SQLAlchemy. I can build a CREATE TABLE statement with a TEMPORARY clause by calling table._prefixes.append('TEMPORARY') on a Table object, but less elegant than table.select().prefix_with() used to add a prefix to language expressions for processing data .

Is there a .prefix_with() equivalent for DDL?

+6
python temp-tables sqlalchemy
source share
1 answer

No, prefix_with() is defined only for SELECT and INSERT. But a convenient way to add a prefix to the CREATE TABLE statement passes it to the table definition:

 t = Table( 't', metadata, Column('id', Integer, primary_key=True), # ... prefixes=['TEMPORARY'], ) 
+7
source share

All Articles