Connections with Microsoft SQL Server are 5 times slower on Linux compared to Windows #1373
-
Beta Was this translation helpful? Give feedback.
Answered by
gordthompson
Aug 4, 2024
Replies: 3 comments 18 replies
-
Are you connecting using SQL Server authentication (UID and PWD) or some other authentication scheme? |
Beta Was this translation helpful? Give feedback.
6 replies
-
acha okay, |
Beta Was this translation helpful? Give feedback.
9 replies
-
@gordthompson it worked on my ubuntu 22.04 system # Use the official Python image from the Docker Hub
FROM python:3.9
# Set the working directory in the container
WORKDIR /Solenoid
# Set Environment variable
ENV PYTHONPATH "${PYTHONPATH}:/Solenoid"
# Set environment variables
ENV ACCEPT_EULA=Y
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y
# Copy only the requirements file first to leverage Docker cache
COPY analysis_service_v9/prod_requirements.txt /app/prod_requirements.txt
# Install Python dependencies
RUN pip install --no-cache-dir -r /app/prod_requirements.txt && \
pip install pandas numpy scipy gunicorn gevent
# Install required packages
RUN apt install -y \
python3 python3-pip \
unixodbc-dev \
libssl-dev \
wget \
curl \
gnupg2 \
dpkg-dev \
gcc \
gnupg \
libbluetooth-dev \
libbz2-dev \
libc6-dev \
libdb-dev \
libexpat1-dev \
libffi-dev \
libgdbm-dev \
liblzma-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
make \
tk-dev \
uuid-dev \
wget \
xz-utils \
zlib1g-dev \
apt-transport-https \
ca-certificates \
build-essential \
gcc \
g++
# Install unixODBC 2.3.12
RUN curl -L http://www.unixodbc.org/unixODBC-2.3.12.tar.gz | tar zx && \
cd unixODBC-2.3.12 && \
./configure && \
make && \
make install && \
cd .. && \
rm -rf unixODBC-2.3.12
# Add the Microsoft repository and install the ODBC driver 18 for SQL Server
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql18 && \
ACCEPT_EULA=Y apt-get install -y mssql-tools18 && \
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> /root/.bashrc && \
. /root/.bashrc
# # Create a symbolic link for the Microsoft SQL Server client library
# RUN ln -s /opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.4.so.1.1 /opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.4.so.1.0
# Copy the application code
COPY analysis_service /app/analysis_service
# Set the working directory
WORKDIR /app
# Expose port 4000
EXPOSE 4000
# Run the application with gunicorn
CMD ["gunicorn", "-w", "2", "-k", "gevent", "-b", "0.0.0.0:4000", "analysis_service.app:app"]
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the wiki update I posted earlier today.
https://github.com/mkleehammer/pyodbc/wiki/Tips-and-Tricks-by-Database-Platform#unixodbc-connection-pooling