Docker image to deploy apps on Python 3.11.1, using pyodbc 4.0.35 and ODBC Driver for MS SQL Server.
4.8K
Docker image to deploy apps on Python 3.11.1, using pyodbc 4.0.35 and ODBC Driver for MS SQL Server.
Check the raw Dockerfile here: https://github.com/cymagix/python-docker-for-pyodbc-sqlserver/blob/main/Dockerfile
Uses official image Python 3.9.10-buster
Example of usage for Dockerfile of FastAPI app:
FROM cymagix/python-for-pyodbc-sqlserver
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --trusted-host pypi.python.org -r requirements.txt
EXPOSE 8000
CMD ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0", "--port", "8000"]
Also, in your Python code, connect as follows:
import pyodbc
def init_connection():
config = ('Driver={ODBC Driver 17 for SQL Server};' +
'Server=127.0.0.1,1433;' +
'Database=yourdb;' +
'UID=SA;' +
'PWD=your@password;')
connection = pyodbc.connect(config)
return connection.cursor()
https://github.com/cymagix/python-docker-for-pyodbc-sqlserver
Content type
Image
Digest
sha256:533d616a7…
Size
422.3 MB
Last updated
almost 4 years ago
docker pull cymagix/python-for-pyodbc-sqlserver