1

I have a Docker Image that's built from this docker file. The docker image is with a Vagrant VM which is Ubuntu 14.04 and I'm running it all in OSX 10.11.6. The Microsoft SQL Server is in an aws-ec2 instance. Since my program is in Python, I have tried 2 python libraries for connecting to the database, but each fail in the same way. Here's an overview of what's happened so far:

  • apk add freetds-dev because FreeTDS needs to be installed for interacting with Microsoft SQL databases.
  • pip install pymssql and pip install pyobdc both fail with the same error message:

{ bash-4.3# pip install pymssql

Collecting pymssql
  Using cached pymssql-2.1.3.tar.gz
    Complete output from command python setup.py egg_info:
    setup.py: platform.system() => 'Linux'
        Download error on     https://pypi.python.org/simple/setuptools_git/:         [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) -- Some packages may not be found!
    Download error on https://pypi.python.org/simple/setuptools-git/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) -- Some packages may not be found!
    Couldn't find index page for 'setuptools_git' (maybe misspelled?)
    Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) -- Some packages may not be found!
    No local packages or download links found for setuptools-git
    setup.py: platform.architecture() => ('64bit', '')
    setup.py: platform.linux_distribution() => ('', '', '')
    setup.py: platform.libc_ver() => ('', '')
    setup.py: Not using bundled FreeTDS
    setup.py: include_dirs = []
    setup.py: library_dirs = ['/usr/local/lib']
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-macbkK/pymssql/setup.py", line 477, in <module>
        ext_modules = ext_modules(),
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 268, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 313, in fetch_build_eggs
        replace_conflicting=True,
      File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 846, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1091, in best_match
        return self.obtain(req, installer)
      File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1103, in obtain
        return installer(requirement)
      File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 380, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 633, in easy_install
        raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('setuptools-git')

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-macbkK/pymssql/

(It's the same error with pyodbc) When I try install setuptools-git (like the error message says), I get a gcc compile error.

In addition to trying pip install..., I've downloaded the SQLAlchemy library directly from the Alpine Linux repo using apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ py-sqlalchemy and the installs still fail/python libraries still fail.

I have found very little documentation on Alpine Linux and Microsoft SQL Server, so I'm wondering if I've missed something that says they're not compatible. Has anyone tried doing this before? If connecting via Python isn't suggested, I am considering connecting via Shell commands, can anyone suggest best practices for this?

Thank you!

zebrainatree
  • 351
  • 1
  • 3
  • 15

3 Answers3

2

you have to install odbc driver first. so, add this to your docker file, and then install pyodbc

apk add g++ gcc unixodbc-dev

Hiran
  • 1,102
  • 11
  • 18
A. Zhilin
  • 31
  • 2
  • 8
    You better explain your solution than just posting some anonymous code section. You should read [How do I write a good answer](https://stackoverflow.com/help/how-to-answer), and also [Explaining entirely code-based answers](https://meta.stackexchange.com/questions/114762/explaining-entirely-%E2%80%8C%E2%80%8Bcode-based-answers). – Massimiliano Kraus Aug 10 '17 at 12:21
  • I encountered `ImportError: No module named Cython.Distutils` for `pymssql` and installed `pip install cython` – f01 Mar 02 '20 at 21:03
  • You also need `apk add python-dev` for Cython – f01 Mar 02 '20 at 21:41
2

Microsoft has officially started supporting ODBC driver installation on Alpine.

Nishant
  • 20,354
  • 18
  • 69
  • 101
0

Related question from me here

I recall installing msodbcsql17 driver to connect to sql server. But I used Ubuntu 18.04 as base image for my docker, and sql server was on azure. Additionally I had to install unixodbc unixodbc-dev gcc g++ gfortran, so not sure if that helps you.

But when I tried for alpine as base image this wasn't possible.

I found a related issue on github but it is under the msphpsql repo so I'm not sure if it applies to the driver in general for alpine. It says MS does not support yet.

Official MS installation page has installation instructions only for Debian, RedHat, SUSE, Ubuntu.