1 How to establish connection between DJANGO & MSSQL in Windows10

preview_player
Показать описание
Windows10
SQL Server 2019
py -V ==== Python 3.9.2
pip -V ==== pip 21.0.1
python -m django --version ==== 3.0

pip list
-----------------------------
Package Version
-------------------- -------
asgiref 3.3.1
Django 3.0
django-mssql-backend 2.8.1
pip 21.0.1
pyodbc 4.0.30
pytz 2021.1
setuptools 54.1.1
sqlparse 0.4.1

# import os,sys
# import pyodbc
# print(drive)
#

# SQL Server
# Oracle in XE
# MySQL ODBC 8.0 ANSI Driver
# MySQL ODBC 8.0 Unicode Driver
# SQL Server Native Client 11.0
# SQL Server Native Client RDA 11.0
# ODBC Driver 17 for SQL Server

DATABASES = {
'default': {
'HOST': 'DESKTOP-U31HLSA\SQLEXPRESS',
'PORT': '',
'NAME': 'DJANGO_MSSQL',
'USER': 'sa',
'PASSWORD': '1234567',

'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
},
},
}|
Рекомендации по теме
Комментарии
Автор

Thank you so much. You saved me a lot of time.

ronaldfungss
Автор

Thankyou so much, I gone through many other solutions through youtube and google ... finally I got success with your solution

minnusworld
Автор

Thank you so much brother.
Keep up the good work!

deepak_dhage
Автор

Sweet.. Thanks so much, perfect instructions

sicmikeg
Автор

This worked perfectly for me. Thank you for uploading this video. Screen should have been in light mode as it's difficult to see.

maathey
Автор

Thank you very much. 👍I want to make this connection for a long time.

subratasadhukhan
Автор

what if its a trusted connection and uses windows authentication?

yameen
Автор

I'm getting login fail...
[ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'xyz'

explorerofinfinity
Автор

i mistakenly migrated before coonecting the database, what to do? i cant see tables in mine

chaitanyasharma
Автор

please can you make video how to view some column table into html in django?

SwahBlauEntertainment
Автор

Can you please explain this for Ubuntu server also?

LifeinBeats
Автор

('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

Bro I'm facing this error
I installed odbc driver manager also and connected also
Can you resolve this?

varadaamrutharatna
Автор

we are not able to connect sql server as per you video followed. pls. help us

rkuvhqb
Автор

showing error AttributeError: 'Query' object has no attribute 'explain_query'

vivekkumaryadav
Автор

Tried for pyodbc, there is error while migration.
pip install mssql-django will be the solution.

jeremyheng
Автор

I am connecting through windows authentication.

MyPakistanilover
Автор

Voice is not clear and also could have changed the dark theme in pycharm

maathey
Автор

Hello there,
I`m using Microsoft SQL server Studio 19 and
other version of django, pip and python are;

asgiref 3.5.2
Django 4.0.6
mssql-django 1.1.3
pip 22.1.2
pyodbc 4.0.34
pytz 2022.1
setuptools 62.6.0
sqlparse 0.4.2
tzdata 2022.1
wheel 0.37.1

the connection string i`m using is given below;

DATABASES = {
'default': {
'ENGINE': 'mssql',
'NAME': 'CDSL',
'USER': 'ASHFAQ-DPO',
'PASSWORD': '218312',
'HOST': 'myserver.database.windows.net',
'PORT': '',

'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
},
},
}
I`m unable to connect SQL with django.
Even when i run python manage.py shell
then import os, sys
import pyodbc
for driver in pyodbc.drivers():
print(driver)
nothing shows, please help to resolve the issue.

when i try to run server following error occur

'sql_server.pyodbc' isn't an available database backend or couldn't be imported. Check the above exception. To use one of the built-in backends, use 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql', 'sqlite3'

MyPakistanilover