Skip to main content
 首页 » 编程设计

python之Alembic bulk_insert 到具有模式的表

2025年05月04日898°冷暖

我正在查看 bulk_insert 中的示例.

# Create an ad-hoc table to use for the insert statement. 
accounts_table = table('account', 
    column('id', Integer), 
    column('name', String), 
    column('create_date', Date) 
) 

我想批量插入 到一个名为kpi 的特定模式,但我不知道该怎么做。有人可以帮帮我吗?

请您参考如下方法:

到目前为止我找到的答案是使用 sqlalchemy 函数,而不是像下面这样:

accounts_table = sa.Table('accounts_table', sa.MetaData(), 
    sa.Column('id', sa.Integer), 
    sa.Column('name', sa.String(100)), 
    sa.Column('create_date', sa.Date), 
    schema='phone' 
)