Install pyodbc: SqlServer
SqlServer - install pyodbc
This is included in Docker, but not for local installs. To install pyodbc
(either global to your machine, or within a venv
):
- Linux
- Mac - using brew:
Install the Microsoft ODBC driver, then:
Unix SQL Server downgrade to 17 in Docker
Running a SQL Server docker image connecting to a client database may require downgrading to version 17 of the unixodbc driver. You can test the installed versions by basing into docker and running this command.
Install build and ODBC unix driver dependencies version 17
# add this to you docker file after the copy command
# devops/docker-image/build_image.dockerfile
RUN apt-get update && \
apt-get install -y curl gnupg apt-transport-https && \
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev gcc g++ python3-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip && \
pip install pyodbc==5.2.0
Please see the examples on the testing for important considerations in specifying SQLAlchemy URIs.
Limitations - SqlServer Sort fields
Note Sql/Server may not sort on certain fields such as images or long text. This shows up, for example, in the Docker SqlServer sample database for Category
. So, when testing these in Swagger, modify your Sort fields accordingly.