i have a django project that need to be connected with MS SQL Server . Iam using pyodbc package in order to make the connection but the problem is that once i try it it crash and display the below error :
djago.db.utils.operationalError:('08001','[08001] [microsoft][odbc sql server driver]neither dsn nor server keyword supplied (0) (sqldriverconnect); [08001] [microsoft][odbc sql server driver] Invalid connection string attribute (0)').
i tried with both authentication mode
this is the views.py
from django.shortcuts import render
import pyodbc
def connect(request):
conn = pyodbc.connect(
'Driver={SQL Server};'
'Server=ip address;'
'Database=I-Base_beSQL;'
'Trusted_Connection=yes;'
)
cursor = conn.cursor()
c = cursor.execute('SELECT "first name" FROM Person WHERE id = 2 ')
return render (request,'connect.html',{"c":c})
or
from django.shortcuts import render
import pyodbc
def connect(request):
conn = pyodbc.connect(
'Driver={SQL Server};'
'Server=ip address;'
'Database=I-Base_beSQL;'
'Trusted_Connection=no;'
'UID=SQLTest;'
'PWD=********;'
)
cursor = conn.cursor()
c = cursor.execute('SELECT "first name" FROM Person WHERE id = 2 ')
return render (request,'connect.html',{"c":c})