HassanAlahmed opened a new issue #22620: URL: https://github.com/apache/airflow/issues/22620
### Apache Airflow version 2.2.4 (latest released) ### What happened Hello, I initialized an sql server hook using the following constructor: `MsSqlHook(mssql_conn_id="connection_id", schema='db_name')` From the package provider: `airflow.providers.microsoft.mssql.hooks.mssql` From the package provider: `airflow.providers.microsoft.mssql.hooks.mssql` Which is based off of this class: `DbApiHook` The problem I'm having is with the DB name that I passed as a parameter to determine which database to run query on. When the DB name is passed through the `schema` parameter, it gets correctly set to the class schema. However, the `DbApiHook.get_conn` method always uses the schema that is coming from the connection and ignores whether `DbApiHook.__schema` has been set or not. ### What you think should happen instead In this line: https://github.com/apache/airflow/blob/main/airflow/hooks/dbapi.py#L91 Instead of having: `schema=db.schema` It should be something like this: `schema = self.__schema or db.schema` ### How to reproduce _No response_ ### Operating System Whatever is in the official latest docker image ### Versions of Apache Airflow Providers `apache-airflow-providers-microsoft-mssql==2.1.0` ### Deployment Docker-Compose ### Deployment details _No response_ ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
