RehanAhmad25 commented on code in PR #74539:
URL: https://github.com/apache/airflow/pull/74539#discussion_r4260294846


##########
providers/microsoft/mssql/docs/connections/mssql.rst:
##########
@@ -74,3 +74,39 @@ If serializing with JSON:
         "port": 1433,
         "schema": "database_name"
     }'
+
+Choosing the DBAPI driver
+-------------------------
+
+By default the hook connects with `pymssql 
<https://pypi.org/project/pymssql/>`__. To use Microsoft's
+`mssql-python <https://pypi.org/project/mssql-python/>`__ driver instead, 
install the extra:
+
+.. code-block:: bash
+
+    pip install 'apache-airflow-providers-microsoft-mssql[mssql-python]'
+
+and set ``dbapi_driver`` to ``mssql_python`` in the connection extra:
+
+.. code-block:: bash
+
+    export AIRFLOW_CONN_MSSQL_DEFAULT='{
+        "conn_type": "mssql",
+        "login": "username",
+        "password": "password",
+        "host": "server.com",
+        "port": 1433,
+        "schema": "database_name",
+        "extra": {"dbapi_driver": "mssql_python", "TrustServerCertificate": 
"yes"}

Review Comment:
   Thanks for pointing this out. I went through the other DB providers to see 
what they do.
   
   For picking a client library through an extra, MySQL is the only precedent, 
and it uses `client` (mysqlclient by default, or mysql-connector-python). JDBC 
uses `driver_path` and `driver_class`, and ODBC's `driver` is the ODBC driver 
name, so I went with `dbapi_driver` to avoid mixing it up with that. If you'd 
rather have `client` for consistency with MySQL, I'm happy to rename it.
   
   On the docs, the other providers lead with a URI example and show the JSON 
form with extras nested under `extra`. I'll add a URI example next to the JSON 
one.
   
   While checking, I also saw that the other hooks raise 
`AirflowOptionalProviderFeatureException` when an optional package is missing, 
so I'll switch the mssql-python import error to that.



-- 
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]

Reply via email to