Using Django with Microsoft SQL Server

106 views
Skip to first unread message

Gerry Seidl

unread,
Jan 7, 2016, 10:34:34 AM1/7/16
to django...@googlegroups.com

Can someone please provide me the details, or point me to documentation on how to connect an existing SQL Server database to a new Django app?

How would the models be built from it?

Thanks,

Gerry

 

 



--------------------------------------------------------
The information transmitted in this email and any of its attachments is intended only for the person or entity to which it is addressed and may contain information concerning Cablevision and/or its affiliates and subsidiaries that is proprietary, privileged, confidential and/or subject to copyright. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient(s) is prohibited and may be unlawful. If you received this in error, please contact the sender immediately and delete and destroy the communication and all of the attachments you have received and all copies thereof.
--------------------------------------------------------

Sid

unread,
Jan 7, 2016, 11:19:18 AM1/7/16
to Django users, GSE...@cablevision.com
I think if you install sql_server.pyodbc it should be fine

UNDER databases in settings.py 
'default': {
        'ENGINE': 'sql_server.pyodbc',
        'NAME': '----------',
        'HOST': '--------',
        'USER': '---------',
        'PASSWORD': '---------'
coding to pull data from sql: https://code.google.com/p/pyodbc/wiki/Cursor

read the documentation for twice you should be fine

whycrying

unread,
Jan 7, 2016, 11:55:47 AM1/7/16
to django...@googlegroups.com
Using django-pyodbc for connecting to SQL Server as Sid said.

Then use the `inspect` management command to build the models ::

    $ python manage.py inspectdb > models.py

via: https://docs.djangoproject.com/en/1.8/howto/legacy-databases/#auto-generate-the-models

Modified models generated to fit your styles.


--
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...@googlegroups.com.
To post to this group, send email to django...@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/5b85f879-19ea-4901-ba67-cfb1926f2566%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

whycrying

unread,
Jan 7, 2016, 11:57:10 AM1/7/16
to django...@googlegroups.com
Sorry. `inspect` -> `inspectdb` .

Reply all
Reply to author
Forward
0 new messages