0

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?

Thanks!

2 Answers 2

1

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:

DATABASES = {
    'default': {
        'NAME': 'databasename',         
        'ENGINE': 'sqlserver_ado',      
        'HOST': 'SERVERNAME\\SQLSERVERINSTANCENAME',    
        'USER': '',                     
        'PASSWORD': '',
        }
    }
0

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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.