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: [email protected] <[email protected]> on behalf 
of sum abiut <[email protected]>
Sent: Monday, February 12, 2018 10:24:07 PM
To: [email protected]
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 
<[email protected]<mailto:[email protected]>> 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 
[email protected]<mailto:[email protected]>.
To post to this group, send email to 
[email protected]<mailto:[email protected]>.
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<https://groups.google.com/d/msgid/django-users/b5577524-e67d-465f-bb49-e54bca92c88b%40googlegroups.com?utm_medium=email&utm_source=footer>.
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 
[email protected]<mailto:[email protected]>.
To post to this group, send email to 
[email protected]<mailto:[email protected]>.
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<https://groups.google.com/d/msgid/django-users/CAPCf-y5CZ-HAUSbGkTWKe23CfuCMWozoLqL85V52924NpDwd-A%40mail.gmail.com?utm_medium=email&utm_source=footer>.
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 [email protected].
To post to this group, send email to [email protected].
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.

Reply via email to