Can I CREATE TEMPORARY TABLE in SQLAlchemy without appending to Table._prefixes?

徘徊边缘 提交于 2019-12-01 01:35:16

问题


I'd like to create a temporary table in SQLAlchemy. I can build a CREATE TABLE statement with a TEMPORARY clause by calling table._prefixes.append('TEMPORARY') against a Table object, but that's less elegant than table.select().prefix_with() used to add a prefix to data manipulation language expressions.

Is there an equivalent to .prefix_with() for DDL?


回答1:


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

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


来源:https://stackoverflow.com/questions/1842902/can-i-create-temporary-table-in-sqlalchemy-without-appending-to-table-prefixes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!