1
votes

I create a new project in django and i was trying to connect to sql server 2019.

So i install sql-server-2019 and after install , i check if ODBC DRIvers was ok, and as you can see , all ok so far.

enter image description here

The next thing i do , was pip install django-pyodbc-azure

enter image description here

I have more packages instaled because i was testing with everyhing i find , and so far i allways have the same error.

enter image description here

it means conn = Database.connect(connstr, django.db.utils.InterfaceError: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name was not found and no predefined driver (0) (SQLDriverConnect) was specified)

and here is my settings.py from django:

enter image description here

I'm stuck here, I don't even know what I can to go on

1
Take a look at this: stackoverflow.com/questions/17115632/…. You can also check out the fork for it: github.com/ESSolutions/django-mssql-backendacw
already do it and don't workPedro Mariz
Please replace the images (other than the first one) with text. Include the full stack trace.aaron
@PedroMariz show DSN de systemas tab and DSN de utilizator tabs as per stackoverflow.com/a/41703602/2067976 answer.Andriy Ivaneyko

1 Answers

3
votes

I would try this:

(1) add 'dsn' entry to DATABASES dictionary as follows:

DATABASES = {
   'default': {
       'ENGINE': 'sql_server.pyodbc',
       ...
       'OPTIONS': {
           'driver': 'ODBC Driver 17 for SQL Server',
           'dsn': 'avariagest',
       },
   }
}

(2) Create a "DSN" named "avariagest":

Go to the "DSN de sistema" tab, in the ODBC administration window, then add and entry called "avariagest" with suitable attributes