Skip to content

Extra parameters in MSSQL Hook breaks sqlalchemy connections #51608

Open
@emredjan

Description

@emredjan

Apache Airflow Provider(s)

microsoft-mssql

Versions of Apache Airflow Providers

apache-airflow-providers-microsoft-mssql==4.4.2

Apache Airflow version

2.10.5

Operating System

RHEL 8.10

Deployment

Virtualenv installation

Deployment details

No response

What happened

Hi. the newly added feature in #44310 breaks existing connections if driver or encrypt parameters are used in the extras:

Probably more parameters may exhibit similar errors. These extras are needed by the MSSQL hook, but we cannot blindly accept these will work in pymssql connections.

Example connection:

{
  "conn_type": "mssql",
  "extra": {
    "driver": "ODBC Driver 18 for SQL Server",
    "encrypt": "yes",
    "sqlalchemy_scheme": "mssql+pyodbc"
  },
    "host": "xxx",
    "login": "xxx",
    "password": "xxx",
    "port": 1433,
    "schema": "master"
}

Errors when using an SQLQueryExecutor using the above connection:

File "src/pymssql/_pymssql.pyx", line 586, in pymssql._pymssql.connect
TypeError: connect() got an unexpected keyword argument 'driver'

File "src/pymssql/_pymssql.pyx", line 586, in pymssql._pymssql.connect
TypeError: connect() got an unexpected keyword argument 'encrypt'

What you think should happen instead

These conenctions should continue working as they did in apache-airflow-providers-microsoft-mssql==3.9.2

How to reproduce

Have MSSQL connections defined with extra parameters
Install apache-airflow-providers-microsoft-mssql >= 4.0.0
Try an mssql hook using sqlalchemy

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions