dosubot[bot] commented on issue #37560:
URL: https://github.com/apache/superset/issues/37560#issuecomment-3822118707

   <!-- Answer -->
   The error means Superset can't find or load the required SQL Server driver 
in your environment. This is common in recent Docker images, where drivers like 
`pymssql` or `pyodbc` are no longer included by default. Even if you installed 
`pymssql`, it may not work reliably on modern Python or Debian images due to 
compatibility issues with SQLAlchemy 2.x and Python ≥3.10. 
   
   The recommended solution is to switch to the `pyodbc` driver and ensure both 
the Microsoft ODBC Driver 18 and the `pyodbc` Python package are installed in 
your Superset image. Here’s how you can do it:
   
   1. **Update your Dockerfile** (for Debian 12/bookworm):
   
      ```dockerfile
      FROM apache/superset:latest
   
      USER root
   
      RUN apt-get update && \
          apt-get install -y build-essential libpq-dev unixodbc-dev curl gnupg2 
&& \
          curl -sSL https://packages.microsoft.com/keys/microsoft.asc | gpg 
--dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \
          curl -sSL https://packages.microsoft.com/config/debian/12/prod.list 
-o /etc/apt/sources.list.d/mssql-release.list && \
          apt-get update && \
          ACCEPT_EULA=Y apt-get install -y msodbcsql18 && \
          pip install --no-cache-dir pyodbc && \
          apt-get clean
   
      USER superset
      ```
      
[Reference](https://github.com/apache/superset/issues/36183#issuecomment-3552040461)
   
   2. **Rebuild your Docker image and restart Superset**.
   
   3. **Use the correct SQLAlchemy connection string** for SQL Server with 
pyodbc, making sure the ODBC string is URL-encoded once (not double-encoded):
   
      ```
      
mssql+pyodbc:///?odbc_connect=Driver%3D%7BODBC+Driver+18+for+SQL+Server%7D%3BServer%3D<your_server>%3BDatabase%3D<your_db>%3BUid%3D<your_user>%3BPwd%3D<your_password>%3BEncrypt%3Dyes%3BTrustServerCertificate%3Dno%3BConnection%20Timeout%3D30%3B
      ```
      
[Reference](https://github.com/apache/superset/discussions/33957#discussioncomment-13640505)
   
   4. **Verify driver installation** by running `python -c "import pyodbc; 
print(pyodbc.drivers())"` inside your container. You should see `ODBC Driver 18 
for SQL Server` in the output.
   
   If you still have issues, please share your exact connection string and 
clarify if you’re running Superset in Docker, Kubernetes, or another 
environment. Also, check the Superset logs for any additional stacktrace 
details.
   
   Let me know if you need a sample Dockerfile for Ubuntu 22.04 or further 
troubleshooting steps!
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/38ba085b-3200-4cd1-9e1f-ebcb2bc1e556?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/38ba085b-3200-4cd1-9e1f-ebcb2bc1e556?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/38ba085b-3200-4cd1-9e1f-ebcb2bc1e556?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/38ba085b-3200-4cd1-9e1f-ebcb2bc1e556?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/38ba085b-3200-4cd1-9e1f-ebcb2bc1e556?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/38ba085b-3200-4cd1-9e1f-ebcb2bc1e556?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/38ba085b-3200-4cd1-9e1f-ebcb2bc1e556?feedback_type=other)</sup>
   
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20error%20means%20Superset%20can%27t%20find%20or%20load%20the%20required%20SQL%20Server%20driver%20in%20your%20environment.%20This%20is%20common%20in%20recent%20Docker%20images%2C%20where%20drivers%20like%20%60pymssql%60%20or%20%60pyodbc%60%20are%20no%20longer%20included%20by%20default.%20Even%20if%20you%20installed%20%60pymssql%60%2C%20it%20may%20not%20work%20reliably%20on%20modern%20Python%20or%20Debian%20images%20due%20to%20compatibility%20issues%20with%20SQLAlchemy%202.x%20and%20Python%20%E2%89%A53.10.%20%0A%0AThe%20recommended%20solution%20is%20to%20switch%20to%20the%20%60pyodbc%60%20driver%20and%20ensure%20both%20the%20Microsoft%20ODBC%20Driver%2018%20and%20the%20%60pyodbc%60%20Python%20package%20are%20installed%20in%20your%20Superset%20i
 
mage.%20Here%E2%80%99s%20how%20you%20can%20do%20it%3A%0A%0A1.%20%2A%2AUpdate%20your%20Dockerfile%2A%2A%20%28for%20Debian%2012/bookworm%29%3A%0A%0A%20%20%20%60%60%60dockerfile%0A%20%20%20FROM%20apache/superset%3Alatest%0A%0A%20%20%20USER%20root%0A%0A%20%20%20RUN%20apt-get%20update%20%26%26%20%5C%0A%20%20%20%20%20%20%20apt-get%20install%20-y%20build-essential%20libpq-dev%20unixodbc-dev%20curl%20gnupg2%20%26%26%20%5C%0A%20%20%20%20%20%20%20curl%20-sSL%20https%3A//packages.microsoft.com/keys/microsoft.asc%20%7C%20gpg%20--dearmor%20%3E%20/etc/apt/trusted.gpg.d/microsoft.gpg%20%26%26%20%5C%0A%20%20%20%20%20%20%20curl%20-sSL%20https%3A//packages.microsoft.com/config/debian/12/prod.list%20-o%20/etc/apt/sources.list.d/mssql-release.list%20%26%26%20%5C%0A%20%20%20%20%20%20%20apt-get%20update%20%26%26%20%5C%0A%20%20%20%20%20%20%20ACCEPT_EULA%3DY%20apt-get%20install%20-y%20msodbcsql18%20%26%26%20%5C%0A%20%20%20%20%20%20%20pip%20install%20--no-cache-dir%20pyodbc%20%26%26%20%5C%0A%20%20%20%20%20%
 
20%20apt-get%20clean%0A%0A%20%20%20USER%20superset%0A%20%20%20%60%60%60%0A%20%20%20%5BReference%5D%28https%3A//github.com/apache/superset/issues/36183%23issuecomment-3552040461%29%0A%0A2.%20%2A%2ARebuild%20your%20Docker%20image%20and%20restart%20Superset%2A%2A.%0A%0A3.%20%2A%2AUse%20the%20correct%20SQLAlchemy%20connection%20string%2A%2A%20for%20SQL%20Server%20with%20pyodbc%2C%20making%20sure%20the%20ODBC%20string%20is%20URL-encoded%20once%20%28not%20double-encoded%29%3A%0A%0A%20%20%20%60%60%60%0A%20%20%20mssql%2Bpyodbc%3A///%3Fodbc_connect%3DDriver%253D%257BODBC%2BDriver%2B18%2Bfor%2BSQL%2BServer%257D%253BServer%253D%3Cyour_server%3E%253BDatabase%253D%3Cyour_db%3E%253BUid%253D%3Cyour_user%3E%253BPwd%253D%3Cyour_password%3E%253BEncrypt%253Dyes%253BTrustServerCertificate%253Dno%253BConnection%2520Timeout%253D30%253B%0A%20%20%20%60%60%60%0A%20%20%20%5BReference%5D%28https%3A//github.com/apache/superset/discussions/33957%23discussioncomment-13640505%29%0A%0A4.%20%2A%2AVerify%20driver%20
 
installation%2A%2A%20by%20running%20%60python%20-c%20%22import%20pyodbc%3B%20print%28pyodbc.drivers%28%29%29%22%60%20inside%20your%20container.%20You%20should%20see%20%60ODBC%20Driver%2018%20for%20SQL%20Server%60%20in%20the%20output.%0A%0AIf%20you%20still%20have%20issues%2C%20please%20share%20your%20exact%20connection%20string%20and%20clarify%20if%20you%E2%80%99re%20running%20Superset%20in%20Docker%2C%20Kubernetes%2C%20or%20another%20environment.%20Also%2C%20check%20the%20Superset%20logs%20for%20any%20additional%20stacktrace%20details.%0A%0ALet%20me%20know%20if%20you%20need%20a%20sample%20Dockerfile%20for%20Ubuntu%2022.04%20or%20further%20troubleshooting%20steps%21)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/supe
 rset/issues/37560)


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to