A docker file to execute tasks requiring python and sql
1.2K
A docker file to execute tasks requiring python and sql.
The repository includes an example in example.py to test if the taskclass works in your environment.
If for some reason, the taskclass does not work for you, report this to the maintainer: [email protected]
The example tests access to an MSSQL Database, so it will need valid credentials (your personal account will not work, if it only allows Windows Authentication. Check with SQL Server Mgmt Studio if you can login with SQL Server Auth as the Authentication method).
To keep the credentials out of all logs, the credentials are best stored in an .env with this content:
DB_HOST={server name}
DB_INSTANCE={instance name}
DB_NAME={database name}
DB_USER={database user}
DB_PWD={database password}
Important! Do not use any quotes around your credentials, otherwise they will end up in your connection string and authentication will not work.
first install the requirements
pip install python_dotenv
pip install sqlserverport
pip install pyodbc
second create the .env file
To run the example, go to the location of the Dockerfile and build it with:
docker build --build-arg http_proxy=http://{insel-user}:{insel-password}@proxy-prod.insel.ch:8080 --build-arg https_proxy=http://{insel-user}:{insel-password}@proxy-prod.insel.ch:8080 .
Now you can run your newly built image with the following command:
docker run --env-file=.env {image-hash}
You should see the following output:
dotenv module missing, continuing with OS environment variables
DB Host: somehost
DB Instance: someinstance
DB Name: somedatabase
User name: username
Password: ********
Using the following SQL Server version:
Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64)
Aug 22 2017 17:04:49
Copyright (C) 2017 Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2016 Standard 10.0 <X64> (Build 14393: )
Especially important in the output is the Microsoft SQL Server XYZ output, which shows you the version of the SQL Server you queried. If you can see the version number, the image works in your environment. Congrats, hopefully in this very moment, your headaches are relieved!
Content type
Image
Digest
Size
230.4 MB
Last updated
over 5 years ago
docker pull idscio/docker-taskclass-python-sql