Connect Sql Server 2014 to Django 2.2

Asked

Viewed 272 times

1

I am trying to connect the Sql Server database to Django but am getting the following error(The connector I am using is Django-pyodbc-Azure):

Django.db.utils.Interfaceerror: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Name of data source not found and no default driver specified (0) (Sqldriverconnect)')

The setings.py configuration:

DATABASES = {
'default': {
    'ENGINE': 'sql_server.pyodbc',
    'NAME': 'name',
    'USER': 'user',
    'PASSWORD': '1234',
    'HOST': '127.0.0.1\test',
    'PORT': '1433',
},}

Dependencies:

Django==2.2.4
django-pyodbc-azure==2.1.0.0

Someone could help with that?

  • That answers your question? Connect SQL Server database to Django

  • The error occurs precisely when trying to use the Django-pyodbc-Azure Nector, which is the suggested setting in the link response.

  • I think the odbc driver is missing. In the package description on Pip there are some https://pypi.org/project/django-pyodbc-azurelinks/

1 answer

0


The problem is the compatibility between Django and python, when I used pyodbc with Python 3.4.4 and Django == 2.2.4 worked, and that’s what I did:

-install Python 3.4.4 CMD Pip install virtualenv test

virtual test

. \ Scripts enable

Pip install Django == 2.2.4 Pip install Django-mssql

Pip install https://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32

Django-admin startproject meuprojeto.

Modify settings database

 DATABASES = {    'default': {
>        'ENGINE': 'sqlserver_ado',
>        'HOST': 'USER-PC\SQL2019',  # Substitua pelo nome do host em que o servidor MSSQL está sendo executado
>        'NAME': 'test',  # Substitua pelo nome do banco de dados no servidor MSSQL
>        'USER': 'USER',  # Substitua pelo nome de usuário
>        'PASSWORD': '1234',  # Substitua pela senha    }, }
  • I did according to your reply but received the following error: Django.core.exceptions.Improperlyconfigured: 'sqlserver_ado' isn’t an available database backend

  • do 'ENGINE': 'sql_server.pyodbc',put the ENGINE you intend to use.

  • Have a look https://answall.com/questions/379211/conectar-banco-dataos-sql-server-no-django?rq=1 have an answer to this problem.

  • I followed that answer before asking, but then I got the error I put in the question. I tried other connectors too but still can not connect.

  • 1

    Beware that Python 3.4 this time is very old and is no longer supported, nor with security updates

Browser other questions tagged

You are not signed in. Login or sign up in order to post.