Connecting Sql server to Django

61 views
Skip to first unread message

Rakhee Menon

unread,
Oct 12, 2018, 12:26:02 AM10/12/18
to Django users


Hi Everyone,

In my project I want to connect SQL Server 2014 with django, I tried with the given link,


but it shows some error like,

            import pythoncom
            ImportError: No module named 'pythoncom''

When I goggled the error it says download pywin32 but I didn't get any file or link to download .Please could anyone help me out with this issue.

Thanks in Advance
Rakhee

vineeth sagar

unread,
Oct 12, 2018, 12:58:52 AM10/12/18
to django...@googlegroups.com
Which version of django are you using, django-mssql only supports Django until 1.8 and it's not under active development. https://pypi.org/project/django-pyodbc-azure/ use this instead, this works with ms-sql as I use this at work and if you go to the bitbucket repo  you'll find the same thing I have explained you.

Apart from that I was forced to use ms-sql at work, what's your reason to use SQL server?

regards
Vineeth

--
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+unsubscribe@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/b1fe3c06-4e5e-45f7-b675-d4751b94337f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rakhee Menon

unread,
Oct 12, 2018, 7:15:15 AM10/12/18
to Django users

Hi Vineeth,
Just had to make some changes in an old project which uses Sql Server 2014 and yeah I am using django 1.8.
Is it that for the link you have given should I use Django 2.1 version or 1.8would work???


Thanks
Rakhee

Jason

unread,
Oct 12, 2018, 8:08:55 AM10/12/18
to Django users
well, considering that 1.8 is no longer supported, you're not getting any backports and updates.  which if you're doing a production level app, is pretty bad.

Unfortunately, seems if you want to use the recent LTS or newer versions, SQL server is not an option unless you're willing to update those packages yourself for compatibility.

vineeth sagar

unread,
Oct 12, 2018, 10:05:11 AM10/12/18
to django...@googlegroups.com
I don't know if it works for 1.8, you would've tested it by now. The link I haven given is a current method to connect with sql server with newer versions of django, also I think it's about time your company updated your django version.  For 2.1 the link I have given works seemlessly.


On Oct 12, 2018 5:38 PM, "Jason" <jjohn...@gmail.com> wrote:
well, considering that 1.8 is no longer supported, you're not getting any backports and updates.  which if you're doing a production level app, is pretty bad.

Unfortunately, seems if you want to use the recent LTS or newer versions, SQL server is not an option unless you're willing to update those packages yourself for compatibility.

--
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.

Pradeep Singh

unread,
Oct 12, 2018, 11:04:54 AM10/12/18
to django...@googlegroups.com
bro...will you help me ...
i am getting django 404 error ...please tell how to fix it...
i am using python 3.6 + django 1.11

Gurmeet Kaur

unread,
Oct 12, 2018, 4:03:43 PM10/12/18
to django...@googlegroups.com
I did it in my project. Use pyodbc to connect to sql server and i am using django 2.0.8

Pradeep Singh

unread,
Oct 14, 2018, 12:52:22 PM10/14/18
to django...@googlegroups.com
please help me why i am getting no change detected

Screenshot (36).png

Pradeep Singh

unread,
Oct 14, 2018, 12:52:47 PM10/14/18
to django...@googlegroups.com
i am newbie in the django..

vineeth sagar

unread,
Oct 14, 2018, 1:04:23 PM10/14/18
to django...@googlegroups.com
Okay Did you put the app in installed_apps in settings.py of your project? Also you are saying you're new to django why would you want to use a ms-sql server as the DB of you're choice? Not something as Postgres or mySQL which have good docs in the Django documentation. I think the above fix should (?) Solve your issue. Maybe all the migrations have been created you have to python manage.py migrate. 

On Oct 14, 2018 10:22 PM, "Pradeep Singh" <reply...@gmail.com> wrote:
i am newbie in the django..

On Sun, 14 Oct 2018 at 22:21, Pradeep Singh <reply...@gmail.com> wrote:
please help me why i am getting no change detected

On Sat, 13 Oct 2018 at 01:33, Gurmeet Kaur <gurmeetka...@gmail.com> wrote:
I did it in my project. Use pyodbc to connect to sql server and i am using django 2.0.8

On Fri, Oct 12, 2018, 11:04 AM Pradeep Singh <reply...@gmail.com> wrote:
bro...will you help me ...
i am getting django 404 error ...please tell how to fix it...
i am using python 3.6 + django 1.11

On Fri, 12 Oct 2018 at 19:35, vineeth sagar <vineeth...@gmail.com> wrote:
I don't know if it works for 1.8, you would've tested it by now. The link I haven given is a current method to connect with sql server with newer versions of django, also I think it's about time your company updated your django version.  For 2.1 the link I have given works seemlessly.

On Oct 12, 2018 5:38 PM, "Jason" <jjohn...@gmail.com> wrote:
well, considering that 1.8 is no longer supported, you're not getting any backports and updates.  which if you're doing a production level app, is pretty bad.

Unfortunately, seems if you want to use the recent LTS or newer versions, SQL server is not an option unless you're willing to update those packages yourself for compatibility.

--
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+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Pradeep Singh

unread,
Oct 14, 2018, 1:07:57 PM10/14/18
to django...@googlegroups.com
yes ..i have put the app name in setting.py .wait i will share all screen shot

On Sun, 14 Oct 2018 at 22:34, vineeth sagar <vineeth...@gmail.com> wrote:
Okay Did you put the app in installed_apps in settings.py of your project? Also you are saying you're new to django why would you want to use a ms-sql server as the DB of you're choice? Not something as Postgres or mySQL which have good docs in the Django documentation. I think the above fix should (?) Solve your issue. Maybe all the migrations have been created you have to python manage.py migrate. 
On Oct 14, 2018 10:22 PM, "Pradeep Singh" <reply...@gmail.com> wrote:
i am newbie in the django..

On Sun, 14 Oct 2018 at 22:21, Pradeep Singh <reply...@gmail.com> wrote:
please help me why i am getting no change detected

On Sat, 13 Oct 2018 at 01:33, Gurmeet Kaur <gurmeetka...@gmail.com> wrote:
I did it in my project. Use pyodbc to connect to sql server and i am using django 2.0.8

On Fri, Oct 12, 2018, 11:04 AM Pradeep Singh <reply...@gmail.com> wrote:
bro...will you help me ...
i am getting django 404 error ...please tell how to fix it...
i am using python 3.6 + django 1.11

On Fri, 12 Oct 2018 at 19:35, vineeth sagar <vineeth...@gmail.com> wrote:
I don't know if it works for 1.8, you would've tested it by now. The link I haven given is a current method to connect with sql server with newer versions of django, also I think it's about time your company updated your django version.  For 2.1 the link I have given works seemlessly.

On Oct 12, 2018 5:38 PM, "Jason" <jjohn...@gmail.com> wrote:
well, considering that 1.8 is no longer supported, you're not getting any backports and updates.  which if you're doing a production level app, is pretty bad.

Unfortunately, seems if you want to use the recent LTS or newer versions, SQL server is not an option unless you're willing to update those packages yourself for compatibility.

--
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.

--
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.

--
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.

--
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.

--
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.

--
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.

Pradeep Singh

unread,
Oct 14, 2018, 1:09:47 PM10/14/18
to django...@googlegroups.com
Screenshot (37).png
Screenshot (38).png

Mateusz

unread,
Oct 14, 2018, 1:17:51 PM10/14/18
to Django users
Line 2: models.Model (capitalize class name)

Pradeep Singh

unread,
Oct 14, 2018, 1:25:10 PM10/14/18
to django...@googlegroups.com
no effect after capitilazation 

Mateusz

unread,
Oct 14, 2018, 1:32:15 PM10/14/18
to Django users
Do you remember to save your work, as Atom does not auto-save by default? I can see the blue dot near the filename on the screenshot, indicating changes in the file that were not saved.
Check if testapp/apps.py contains config class with a name variable. Something similar to the code below:
from django.apps import AppConfig

class TestappConfig(AppConfig):
   name
= 'testapp'

Gurmeet Kaur

unread,
Oct 14, 2018, 8:51:26 PM10/14/18
to django...@googlegroups.com
Can you please share your settings.py file and requirements.txt?

sum abiut

unread,
Oct 14, 2018, 9:50:11 PM10/14/18
to django...@googlegroups.com


using the pymssql driver, you can do something like this

from sqlalchemy import create_engine

def connect(request):
    engine=create_engine('mssql+pymssql://username:password@hostname /db')
    connection=engine.connect()
    
hope this helps.


--
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.

Pradeep Singh

unread,
Oct 14, 2018, 10:06:48 PM10/14/18
to django...@googlegroups.com
thanks ..@mateusz now its working....

Rakhee Menon

unread,
Oct 16, 2018, 1:06:53 AM10/16/18
to Django users
Hey!VineethThanks a lot...It worked...

Rakhee Menon

unread,
Oct 16, 2018, 1:38:18 AM10/16/18
to Django users

Hey Vineeth,
 
The last link which you gave worked like a pro..Thanks a lot for it...Could you please help me out with one more issue...
    As all my tables have been created in my old project I just want to access those tables using Django so without creating models how to access the table data?

   For eg: If PartyMaster is a table Using ORM one would have used it as PartyMaster.objects.get() however in the same manner how can I get or access data from database with models in Django??

  Thank You
  Regards
  Rakhee
Reply all
Reply to author
Forward
0 new messages