【问题标题】:Issue with using alembic with Azure Synapse SQL DW将 alembic 与 Azure Synapse SQL DW 一起使用的问题
【发布时间】:2021-11-20 15:17:36
【问题描述】:

我正在尝试为 Azure Synapse DW 创建 Alembic 迁移。我不断收到以下错误:

[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]111214;An attempt to complete a transaction has failed. No corresponding transaction found.

alembic.ini 文件中我的连接字符串是:

sqlalchemy.url = mssql+pyodbc:///?odbc_connect=Driver={ODBC Driver 17 for SQL Server};Server=tcp:{host},1433;Database={database};Uid=sqladminuser;Pwd={Password};Encrypt=yes;TrustServerCertificate=no;Connection+Timeout=30;

我正在尝试迁移的版本:

def upgrade():
    op.create_table(
        'test',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('description', sa.String, nullable=False),
        sa.Column('source_type', sa.String, nullable=False),
        sa.Column('source_schema', sa.String, nullable=False),
        sa.Column('source_entity', sa.String, nullable=False),
    )


def downgrade():
    op.drop_table('test')

【问题讨论】:

标签: sql-server sqlalchemy pyodbc alembic azure-synapse


【解决方案1】:

我按照 Gord 在 cmets 中提供的 github 链接解决了这个问题。我通过 sqlalchemy.url 更新为

mssql+pyodbc://{user}:{password}@{host/server}:1433/{db}?autocommit=True&driver=ODBC+Driver+17+for+SQL+Server

【讨论】:

    猜你喜欢
    • 2021-11-20
    • 2020-12-27
    • 2021-03-18
    • 2017-07-28
    • 2021-08-26
    • 2020-12-13
    • 2020-08-21
    • 2021-11-15
    • 1970-01-01
    相关资源
    最近更新 更多