I have a django project that make a connection between django and SQL 
server  the problem is that once the system run it 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 know that the code 08001 mean *Client unable to establish connection*

But all the credentials are correct. What am I missing here?



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})

connect.html

    {% for row in c %}
    {{ row }}
    {% endfor %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7da39e65-4304-4929-98bb-ce19edab7372%40googlegroups.com.

Reply via email to