Using Django with an existing Sql Sever database

1

I'm trying to test Django with a database in Sql Server that already exists.

I have searched for documentation, and everything points to using the Inspectdb ( python mysite/manage.py inspectdb > mysite/myapp/models.py ) command.

This does not work for me, the documentation also mentions the configuration at settings.py (Engine - Name - User - Password) in the "Databases" section.

Could someone please guide me about it? Any testimony of applications developed in Django against Sql Server?

    
asked by Jesús Seijas 01.03.2018 в 19:45
source

2 answers

0

The Inspectdb is for viewing or creating models from an existing database. It's weird that it does not work for you. Are you sure that the user with whom you are trying to access the database has the necessary permissions?

    
answered by 02.03.2018 в 16:15
0

You have to install django-pyodbc-azure == 1.11.0.0 pyodbc == 4.0.17

And in settings DATABASES = {     'default': {         'ENGINE': 'sql_server.pyodbc',         'NAME': 'Name of the BDD',         'USER': 'user',         'PASSWORD': 'password',         'HOST': '127.0.0.1',         'PORT': '1433',         'OPTIONS': {             'driver': 'SQL Server Native Client 10.0',             #Depends on the SQL driver --- link            }     } }

    
answered by 02.03.2018 в 16:27