I have a Django site running on a Linux based server. My partner has SQL Server running on a IIS Windows server behind a Cisco router. We are looking for a secure way for the Django site to connect to SQL server and interact with the database.

Currently we are solving the problem by running a shell script in a cron job that !) starts the VPN using vpnc, 2) runs python code (pyodbc) and writes the results to sqlite db, 3) disconnects the VPN. Then in the django code we access the sqlite database. This solution seems pretty obtuse.

The ideal approach would be to have pyodbc connect directly and securely to SQL Server. Anyone know how to accomplish this?


2 Answers 2


There is a site-package available for connecting Django to Microsoft SQL Server. Check this out: http://django-mssql.readthedocs.org/en/latest/.

You would then modify your DATABASE settings to something like this:

    'default': {
        'NAME': 'databasename',         
        'ENGINE': 'sqlserver_ado',      
        'USER': '',                     
        'PASSWORD': '',

Well, you have the solution already: start the VPN and use that VPN connection for the traffic from your django app to the SQL Server database...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .