Re: How to fetch data from sql server and display on django web pages

2018-02-13 Thread PASCUAL Eric
Hi,


> You may want to check out sqlalchemy they provide a pretty good documentation 
> on what you are aftering


For my understanding, why are you suggesting to use SQLAlchemy while Django 
provides an ORM out of the box ?


SQLAlchemy is required for frameworks such as Flask, which do nothing with 
respect to the data layer, but it's not clear which benefit it could bring here.


Best regards


Eric

From: django-users@googlegroups.com  on behalf 
of sum abiut 
Sent: Monday, February 12, 2018 10:24:07 PM
To: django-users@googlegroups.com
Subject: Re: How to fetch data from sql server and display on django web pages


You may want to check out sqlalchemy they provide a pretty good documentation 
on what you are aftering 
http://docs.sqlalchemy.org/en/latest/dialects/mssql.html

>From you view you can defile a function like so.

view.py

from sqlalchemy import*
from django.shortcuts import render

def connectto_db(request):
engine=create_engine('mssql+pymssql://username:password@servername 
/Ddabname')
connection=engine.connect()
metadata=MetaData()


table=Table('tablename',metadata,autoload=True,autoload_with=engine)
stmt='SELECT * FROM table'
results=connection.execute(stmt).fetchall()
return render(request,'template.html',locals())


then  you can pass the results to your template.html

Hope this helps.

Cheers

On Sun, Feb 11, 2018 at 4:37 PM, Amit Kadivar 
> wrote:
Please Help me.
How to fetch data from sql server and display them on django web pages through 
nginx web server..




--
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 post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5577524-e67d-465f-bb49-e54bca92c88b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

--
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 post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5CZ-HAUSbGkTWKe23CfuCMWozoLqL85V52924NpDwd-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/AM5P193MB008317CB26D147DD042FD98A8CF70%40AM5P193MB0083.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: How to fetch data from sql server and display on django web pages

2018-02-12 Thread sum abiut
You may want to check out sqlalchemy they provide a pretty good
documentation on what you are aftering
http://docs.sqlalchemy.org/en/latest/dialects/mssql.html

>From you view you can defile a function like so.

view.py

from sqlalchemy import*
from django.shortcuts import render

def connectto_db(request):
engine=create_engine('mssql+pymssql://username:password@servername
/Ddabname')
connection=engine.connect()
metadata=MetaData()


table=Table('tablename',metadata,autoload=True,autoload_with=engine)
stmt='SELECT * FROM table'
results=connection.execute(stmt).fetchall()
return render(request,'template.html',locals())


then  you can pass the results to your template.html

Hope this helps.

Cheers

On Sun, Feb 11, 2018 at 4:37 PM, Amit Kadivar 
wrote:

> Please Help me.
> How to fetch data from sql server and display them on django web pages
> through nginx web server..
>
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b5577524-e67d-465f-bb49-e54bca92c88b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



--

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5CZ-HAUSbGkTWKe23CfuCMWozoLqL85V52924NpDwd-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fetch data from sql server and display on django web pages

2018-02-11 Thread carlos
maybe try with this app
http://django-mssql.readthedocs.io/en/latest/settings.html

On Sun, Feb 11, 2018 at 3:58 AM, PASCUAL Eric  wrote:

> Hi Amit,
>
>
> There is no "Django Web page" as you write in your message, but Web pages
> of the application built on top of the Django framework. Hence how to
> display data depends on how the Web pages of **your** application are
> designed.
>
>
> Second point, one of the roles of Django is to isolate the application
> developer from the raw SQL requests needed to store and retrieve data from
> the underlying data base. This is called an ORM (object relational mapping)
> and it is one of the keystones of the Django framework. The benefit from
> this is that you don't have to deal with SQL requests *(at least for the
> vast majority of the situations)*, but to specify the data model of the
> application as a collection of classes and relations between them. Django
> tools will take care of creating the relational database first, and then
> translate under the hood the object oriented interactions you make with
> your model into the corresponding SQL requests.
>
>
> I've the feeling that you have not fully understood what Django is, what
> Django does and how to write a Django application. So, take no offense,
> but have you read (and understood) at least the introduction (including
> tutorials) documentation of Django ?
>
>
> What is exactly the context of your project, what is it supposed to do,...
> ? The way you are presenting it, it sounds a bit like a student homework.
> Maybe it's not, but...
>
>
> Best regards.
>
>
> Eric
> --
> *From:* django-users@googlegroups.com  on
> behalf of Amit Kadivar 
> *Sent:* Sunday, February 11, 2018 6:37:28 AM
> *To:* Django users
> *Subject:* How to fetch data from sql server and display on django web
> pages
>
> Please Help me.
> How to fetch data from sql server and display them on django web pages
> through nginx web server..
>
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b5577524-e67d-465f-bb49-e54bca92c88b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/AM5P193MB00835F3E9901536A3FF319C28CF00%40AM5P193MB0083.
> EURP193.PROD.OUTLOOK.COM
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
att.
Carlos Rocha

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAM-7rO2Gd0Q18_1%2BVyse3ej%2BFmeok6eb2srjEaUajPqr4FbqUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fetch data from sql server and display on django web pages

2018-02-11 Thread PASCUAL Eric
Hi Amit,


There is no "Django Web page" as you write in your message, but Web pages of 
the application built on top of the Django framework. Hence how to display data 
depends on how the Web pages of *your* application are designed.


Second point, one of the roles of Django is to isolate the application 
developer from the raw SQL requests needed to store and retrieve data from the 
underlying data base. This is called an ORM (object relational mapping) and it 
is one of the keystones of the Django framework. The benefit from this is that 
you don't have to deal with SQL requests (at least for the vast majority of the 
situations), but to specify the data model of the application as a collection 
of classes and relations between them. Django tools will take care of creating 
the relational database first, and then translate under the hood the object 
oriented interactions you make with your model into the corresponding SQL 
requests.


I've the feeling that you have not fully understood what Django is, what Django 
does and how to write a Django application. So, take no offense, but have you 
read (and understood) at least the introduction (including tutorials) 
documentation of Django ?


What is exactly the context of your project, what is it supposed to do,... ? 
The way you are presenting it, it sounds a bit like a student homework. Maybe 
it's not, but...


Best regards.


Eric

From: django-users@googlegroups.com  on behalf 
of Amit Kadivar 
Sent: Sunday, February 11, 2018 6:37:28 AM
To: Django users
Subject: How to fetch data from sql server and display on django web pages

Please Help me.
How to fetch data from sql server and display them on django web pages through 
nginx web server..




--
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 post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5577524-e67d-465f-bb49-e54bca92c88b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/AM5P193MB00835F3E9901536A3FF319C28CF00%40AM5P193MB0083.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.