how to run a function from a link withing popup modal bootstrap with django
I have a django project that includes a popup modal where the modal has tabs as links one of these tabs once the user clicked it must perform a function and retrieve data from the database. The problem is that once the user clicked the tab nothing happen as is the function isn't initialize. urls.py path("events//", getEvents, name = "getEvents"), views.py def getEvents(request,id): q1 = cursor.execute('SELECT Person_.ID FROM Person_ WHERE Person_.ID = {0}'.format(id)) print('q1==>',q1) qresult = q1.fetchone() print("qresult==>",qresult) print("query is not empty!") eventQ = cursor.execute('SELECT Person_.ID, Person_.Full_Name, Events.ID, Events.Event_Title, Events.Event_Details, Links.document_id from Person_, Events, Links where ( Person_.ID = {0}) and (Person_.ID = Links.A_Person or Person_.ID = Links.B_Person) and (Events.ID = Links.A_Event or Events.ID = Links.B_Event) ORDER BY Events.ID DESC '.format(id)) resultEvents = eventQ.fetchall() return render(request,'pictureCard.html',{ "resultEvents":resultEvents, "qresult":qresult, }) pictureCrads.html {% for obj in object_list %} {{ obj.1 }} contact us Events Picture {{ obj.9 }} {% for event in resultEvents %} events {{ event.2 }} {% endfor %} {% endfor %} .. detais https://groups.google.com/d/msgid/django-users/39c2de7c-65ec-4b79-8e55-ca6ad9128fa7%40googlegroups.com.
how to retrieve data from database using raw SQL not django ORM
0 I have a django project that is connected to SQL server database and when i tried to click button to retrieve data from the database the system crash . i am trying to convert the below syntax in ORM into raw sql: dbEntry = Person_.objects.get(pk =pk) Note : *I am not using ORM* once i tried to perform the task the system crash and display: getEvents() got unexpected keyword argument "id" urls.py path("events//",getEvents,name = "getEvents"), views.py def getEvents(request,pid): q1 = cuesor.execute("Select Person_.ID FROM Person_ WHERE ID = pid") print("q1=",q1) qresult = q1.fetchone() print("qresult",qresult) return render(request,"connect.html",{"qresult":qresult}) list.html get details display.html {% for row in qresult %} {{ row.0 }} {% 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/12fcc5c9-960d-4690-b479-bcbddb04ea99%40googlegroups.com.
django print all record in the cmd but display the last one on template
i have a function that retrieve data from sql server database where i am using **fetchall()** then for loop the retrieved data are all printed on the **cmd console** but when i tried to display these result on the template it **only display the last record**. views.py def search(request): query = cursor.execute('Select id, fullname from person') result = query.fetchall() for row in result: print("ID==>",id) IPD=row[0] return render(request,"test.html",{"IPD":IPD}) test.html {{ IPD }} -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/68025e0a-81cf-4e62-bd15-14e2006e0157%40googlegroups.com.
Re: HOW TO DISPLAY THE COLLAPSED DATA IN CARD using django and bootstrap
js and bootstrap files are loaded correctly. On Saturday, September 28, 2019 at 10:56:41 AM UTC+3, leb dev wrote: > > I have a django project that includes cards where each card contains a > collapse that will hide or show the data. > > Problem is once i do a **foreach loop** the cards appear but the collapse > is not working and doesn't display any data. > > I used the below steps: > > create function in views.py > > > def displaydata(request,pk): > c = cursor.execute('SELECT ID,Nickname_,Date_of_Birth FROM Person_ > WHERE ID = pk ') > print("c ===>",c) > return redirect("search") > return render(request,"displaydata.html",{"c":c}) > > create URL in urls.py > == > > path("displaydata//",displaydata,name = "displaydata") > > create a template that display the cards > = > > > > {% for obj in object_list %} > > > > > > > alt="..."> > > > "#table-collapsed" caller-id ="" aria-controls="collapse-collapsed" > id="heading-collapsed{{obj.0}"> > > Details > > > > $(document).on('click','.collapsed d-block',function(){ > > $('#heading-collapsed').attr('caller-id',$(this).attr('id')); > }); > > > > > > > create a template that display the **collapsed data** > = > > {% for row in c %} > aria-labelledby="heading-collapsed"> > > > > NICKNAME > {{ row.1 }} > > > DOB > {{ row.2 }} > > > > > > {% 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b9f6644b-fe3b-4b5e-9838-cc06d194fb42%40googlegroups.com.
HOW TO DISPLAY THE COLLAPSED DATA IN CARD using django and bootstrap
I have a django project that includes cards where each card contains a collapse that will hide or show the data. Problem is once i do a **foreach loop** the cards appear but the collapse is not working and doesn't display any data. I used the below steps: create function in views.py def displaydata(request,pk): c = cursor.execute('SELECT ID,Nickname_,Date_of_Birth FROM Person_ WHERE ID = pk ') print("c ===>",c) return redirect("search") return render(request,"displaydata.html",{"c":c}) create URL in urls.py == path("displaydata//",displaydata,name = "displaydata") create a template that display the cards = {% for obj in object_list %} Details $(document).on('click','.collapsed d-block',function(){ $('#heading-collapsed').attr('caller-id',$(this).attr('id')); }); create a template that display the **collapsed data** = {% for row in c %} NICKNAME {{ row.1 }} DOB {{ row.2 }} {% 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4e300433-1840-4f00-9e88-2109d9da625d%40googlegroups.com.
Re: where is the error in pagination?
> > >> >> >> >> {% if object_list.has_previous %} >> >> first >> >> previous >> >> {% endif %} >> >> >>> >> >> Page {{ object_list.number }} of {{ >>> object_list.paginator.num_pages }}. >> >> >> >> >>> {% if object_list.has_next %} >> >> next >> >> last >> >> {% endif %} >> >> >> >> >> >> On Wednesday, September 25, 2019 at 2:39:16 PM UTC+3, laya Mahmoudi wrote: > > Would you send your html codes relating to pagination > > در تاریخ چهارشنبه ۲۵ سپتامبر ۲۰۱۹، ۱۵:۰۳ leb dev > نوشت: > >> i tried your answer and display an error : >> >> That page number is not an integer >> >> -- >> 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 django...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/0323b126-726e-4889-beee-b68988b1a3f1%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/0323b126-726e-4889-beee-b68988b1a3f1%40googlegroups.com?utm_medium=email_source=footer> >> . > > -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0ad0f775-92f0-4621-b491-5d97a7f9270a%40googlegroups.com.
Re: where is the error in pagination?
i tried your answer and display an error : That page number is not an integer -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0323b126-726e-4889-beee-b68988b1a3f1%40googlegroups.com.
Re: where is the error in pagination?
no i am using function based views -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/bf45aef0-f237-43b4-b7fd-49bea6673b36%40googlegroups.com.
where is the error in pagination?
i have a django project and it includes pagination i do not know where is the error in my code but once i tired to go to the next or previous page it crash and display the below error : > can only concatenate str(not ""NoneType) to str query=request.GET.get("search") paginator = Paginator(queryset_list, 5) page_request_var = "page" print("page_request_var===>",page_request_var) page = request.GET.get(page_request_var) print("page===>",page) queryset = paginator.get_page(page) print("queryset===>",queryset) When i print **page** it display None In the browser it suppose to display **page=2=sam** but instead it display **/?=2&20search%20=%20sam** -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/82e3fe0e-e872-4a49-b869-2b67001e3270%40googlegroups.com.
how to use django pagination with sql query and not ORM
I now how to use django pagination with ORM django after filtering the required data and put in into *pagination div* *queryset_list = employee.objects.all()* *query=request.GET.get("q")* *if query:* *queryset_list=queryset_list.filter(* * Q(name__icontains=query)|* * Q(father_name__icontains=query)|* * Q(mother_name__icontains=query)|* * Q(content__icontains=query)|* * Q(create_date__icontains=query)* * # Q(user__first_name__contains=query)* *).distinct()* *paginator = Paginator(queryset_list, 5)* *page_request_var = "page"* *page = request.GET.get(page_request_var)* *queryset = paginator.get_page(page)* *context={* *"object_list":queryset,* *"title":"List Items",* *"page_request_var":page_request_var,* *}* *return render(request,"blog/list.html", context)* the above code is working my question is how to convert this ORM into raw SQL i know that i must use LIMIT and OFFSET in raw SQL to embedded into paginator. -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2d44b204-8520-423a-992c-597fd479f856%40googlegroups.com.
How to retrieve data from MS SQL using wildcard with LIKE
I have a django project that is connected to MS SQL using **pyodbc**. I am able to connect and retrieve data. But the problem is when i tried to filter the data on multiple fields using **WHERE & LIKE** the system crash crash and display the below error. > 'tuple' object has no attribute 'format' views.py from django.shortcuts import render import pyodbc def connect(request): conn = pyodbc.connect( 'Driver={ODBC Driver 17 for SQL Server};' 'Server=DESKTOP-LPD1575\\SQLEXPRESS;' 'Database=testDB;' 'UID=test;' 'PWD=test;' ) query = 'n' queryid = 3 cursor = conn.cursor() c = cursor.execute('SELECT * FROM Artist where artistName like ? or id = ?',('%{0}%','{1}').format(query,queryid)) print(c) return render (request,'connect.html',{"c":c}) connect.html == id FolderNumber Folderdate {% for row in c %} {{ row.0 }} {{ row.1 }} {{ row.2 }} {% 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0913c12c-942b-472f-bc77-33f4b576235a%40googlegroups.com.
how to use sql select query with pyodbc and django ?
i have a django code that connect to sql server database and i am trying to select values using *like *but once i try it it crash and the system display the below error: ('The SQL contains 0 parameter markers, but 1 parameters were supplied', 'HY000') views.py from django.shortcuts import render import pyodbc # from .models import Artist # Create your views here. def connect(request): conn = pyodbc.connect( 'Driver={ODBC Driver 17 for SQL Server};' 'Server=DESKTOP-LPD1575\\SQLEXPRESS;' 'Database=testDB;' 'UID=test;' 'PWD=*;' ) query = 'jhon' cursor = conn.cursor() c = cursor.execute('SELECT * FROM Artist where artistName like "%?%"',query) print(c) return render (request,'connect.html',{"c":c}) connect.html == id FolderNumber Folderdate {% for row in c %} {{ row.0 }} {{ row.1 }} {{ row.2 }} {% 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/485f0fc0-c340-460c-aef3-00177c8a2ef7%40googlegroups.com.
how to pass user input into raw sql query ?
i have a django project that is connected to sql server database i am trying to write a *select query * #convert the Django ORM into SQL query print("sql query = ",FilterQuery.query) *select * from table name where filed name = user input * *can anyone help me with this?* -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fa888770-2a9a-4ff6-951b-be085c15cda8%40googlegroups.com.
display vakues in table in template
i have a django project that is connected to SQL Server i tried to retrieve data from the database. if i try to display all the data it run correct and display all the values. but if i try to display the data in an **html table** it doesn't display anything. views.py === def connect(request): conn = pyodbc.connect( 'Driver={ODBC Driver 17 for SQL Server};' 'Server=DESKTOP-LPD1575\\SQLEXPRESS;' 'Database=testDB;' 'UID=test;' 'PWD=test;' ) cursor = conn.cursor() c = cursor.execute('SELECT * FROM Artist') return render (request,'connect.html',{"c":c}) connect.html ID FolderNumber Title {% for row in c %} {% for item in row %} {{ item }} {% endfor %} {% endfor %} anyone can help me? -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0983db04-7547-47a4-ab5a-71deef3dc55a%40googlegroups.com.
how to display retrieved data from database using django
i have a django project that is connected to SQL Server i tried to retrieve data from the database. if i try to display all the data it run correct and display all the values. but if i try to display the data in an **html table** it doesn't display anything. views.py === def connect(request): conn = pyodbc.connect( 'Driver={ODBC Driver 17 for SQL Server};' 'Server=DESKTOP-LPD1575\\SQLEXPRESS;' 'Database=testDB;' 'UID=test;' 'PWD=test;' ) cursor = conn.cursor() c = cursor.execute('SELECT * FROM Artist') return render (request,'connect.html',{"c":c}) connect.html {% for row in c %} {{ row }} {% endfor %} this code in the html template work and display the data. but if i try to do as below it will not work ID FolderNumber Title {% for row in c %} {{ row.id }} {{ row.artistName }} {{ row.activeFrom }} {% endfor %} anyone can help me? -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f4760501-db2c-467d-8746-51fdcf9265f1%40googlegroups.com.
Re: help me to fix this issue with database connection
yes i am on the same LAN and i am able to get remote connection and ping -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3c85bc5a-717d-41fe-b399-30a1ed9f7a40%40googlegroups.com.
Re: help me to fix this issue with database connection
yes i can get a remote connection with the server and i can do ping so its reachable. and about the port its the default port used to connect ms sql server 1433. isn't this right ? -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cd42cf20-4abd-49db-a581-df7aa7a61ef5%40googlegroups.com.
Re: help me to fix this issue with database connection
i tried your answer also and did not work i do not know what is the problem and how to fix it -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/28dc899d-d6e5-4767-b3a1-bec89e6e5248%40googlegroups.com.
Re: help me to fix this issue with database connection
i already installed pyodbc package. And add below code in settings.py. DATABASES = { *'default'*: { *'ENGINE'*: *'sql_server.pyodbc'*, *'NAME'*: *'DB'*, *'USER'*: *'user'*, *'PASSWORD'*: *'pwd’*, *'HOST'*: *'host'*, *'OPTIONS'*: { *'driver'*: *'ODBC Driver 17 for SQL Server'*, }, } } On Thursday, August 29, 2019 at 11:22:35 AM UTC+3, doddahulugappa wrote: > > > > Pip install pyodbc > > And add below code snipped in settings.py. it should work. I am using in > this way. It works perfectly > > DATABASES = { > *'default'*: { > *'ENGINE'*: *'sql_server.pyodbc'*, > *'NAME'*: *'DB'*, > *'USER'*: *'user'*, > *'PASSWORD'*: *'pwd’*, > *'HOST'*: *'host'*, > *'PORT'*: *'port'*, > *'OPTIONS'*: { > *'driver'*: *'ODBC Driver 17 for SQL Server'*, > *'isolation_level'*: *'READ UNCOMMITTED'*, > *# prevent SELECT deadlocks*}, > } > > } > > > > > > *From:* 'Amitesh Sahay' via Django users [mailto: > django...@googlegroups.com ] > *Sent:* Thursday, August 29, 2019 12:16 PM > *To:* Django users > *Subject:* Re: help me to fix this issue with database connection > > > > DATABASES = { > 'default': { > 'ENGINE': 'django.db.backends.postgresql', > 'NAME': 'Authenticate', # database name > 'USER': 'postgres', > 'PASSWORD': 'pwd', > 'HOST': 'localhost' > } > } > > I don't think you need anything other than this. For MySql you can use > mysql driver "*django*.*db*.*backends*.*mysql*". I hope that works. > > > > Regards, > > Amitesh Sahay > > > > > > On Thursday, 29 August, 2019, 01:41:44 pm IST, leb dev > wrote: > > > > > > i tried in the settings.py > > DATABASES = { > > 'default': { > > 'ENGINE': 'sql_server.pyodbc', > > 'NAME': 'testDB', > > 'HOST': 'VSQLSERV', > > 'OPTIONS': { > > 'driver':' SQL Server', > > } > > > > # 'ENGINE': 'django.db.backends.sqlite3', > > # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), > > } > > } > > > On Thursday, August 29, 2019 at 8:34:17 AM UTC+3, leb dev wrote: > > i have a django project that need to be connected to MS SQL Server i am > using *pyodbc package.* > > > > *once i run the program the system 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)') > > > > where is the error and how to fix it ? > > > > 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}) > > -- > 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 django...@googlegroups.com . > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/django-users/a1cdc16f-4cb0-4d47-872c-7c9320023263%40googlegroups.com > > <https://groups.google.com/d/msgid/django-users/a1cdc16f-4cb0-4d47-872c-7c9320023263%40googlegroups.com?utm_medium=email_source=footer> > > . > > -- > 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 django...@googlegroups.com . > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/1697008900.237063.1567066571422%40mail.yahoo.com > > <https://groups.google.com/d/msgid/django-users/1697008900.237063.1567066571422%40mail.yahoo.com?utm_medium=email_source=footer> > . > -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/39fc2138-1168-4d7a-b55c-823df8e72010%40googlegroups.com.
Re: help me to fix this issue with database connection
i tried in the settings.py DATABASES = { 'default': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'testDB', 'HOST': 'VSQLSERV', 'OPTIONS': { 'driver':' SQL Server', } # 'ENGINE': 'django.db.backends.sqlite3', # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } On Thursday, August 29, 2019 at 8:34:17 AM UTC+3, leb dev wrote: > > i have a django project that need to be connected to MS SQL Server i am > using *pyodbc package.* > > *once i run the program the system 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)') > > where is the error and how to fix it ? > > 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}) > > -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a1cdc16f-4cb0-4d47-872c-7c9320023263%40googlegroups.com.
help me to fix this issue with database connection
i have a django project that need to be connected to MS SQL Server i am using *pyodbc package.* *once i run the program the system 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)') where is the error and how to fix it ? 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}) -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4bdca932-9293-409e-a144-ef535d138422%40googlegroups.com.
how to connect django with SQL Server ?
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}) -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f2b220b3-be7a-47eb-a6ae-d4b040ef7cc1%40googlegroups.com.
Establish a connection between django and SQL Server using pyodbc
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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7da39e65-4304-4929-98bb-ce19edab7372%40googlegroups.com.