ASHISH M.G
ASHISH M.G

Reputation: 802

Issue with using alembic with Azure Synapse SQL DW

Im trying to create alembic migrations for Azure Synapse DW. Im constantly getting following error :

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

My connection string in alembic.ini file is :

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;

Version im trying to migrate :

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')

Upvotes: 2

Views: 522

Answers (1)

ASHISH M.G
ASHISH M.G

Reputation: 802

I resolved this by following the github link provided by Gord in the comments. I updated by sqlalchemy.url to

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

Upvotes: 2

Related Questions