开发者

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

开发者 https://www.devze.com 2022-12-13 16:28 出处:网络
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 l

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?


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'],
)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号