[IMPORTANT] In most cases you want to use official docker image an article
First install on virtual box Windows Xp and MS SQL server 2005
How to connect ms sql server from mac https://stackoverflow.com/a/37616522/3411682
If you get error while restoring bak file try to use TSQL
restore filelistonly from disk='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\INTCON20170815.bak';
to check files which need to move
RESTORE DATABASE INTCON FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\INTCON20170815.bak' with move 'verINTCON' to 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\INTCON.mdf', move 'verINTCON_log' to 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\INTCON_log.ldf'
[IMPORTANT] If you use django > 1.7.x try to use django-pymssql
I was not able to run django_pyodbc on my mac so I used docker image.
*Dockerfile*
FROM lbosqmsft/mssql-python-pyodbc
RUN apt-get install -y freetds-dev
RUN apt-get install -y tdsodbc
EXPOSE 80
ADD . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
To run docker
docker run -it -v "$PWD":/app -p 1433:1433 -p 8000:8000 nmodes /bin/bas
Or docker-compose up
see the docker-compose.yml
Now you will able to connect to your mssql on 192.168.65.1:1433
#django setting
DATABASES = {
'default': {
'ENGINE': 'django_pyodbc', # ! you have to install it
'NAME': 'your_DB',
'HOST': '192.168.65.1',
'USER': 'admin',
'PASSWORD': 'your_password',
'PORT': 1433,
'OPTIONS': {
'driver_needs_utf8': True,
'decode_unicode': None,
'client_encoding': 'utf-8',
'driver': '/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so',
'host_is_server': True,
'extra_params': "TDS_VERSION=8.0",
'autocommit': True,
}
}
}