Wednesday, March 27, 2019

Re: Create models using raw SQL queries

hi Cameron, as Eric said, by doing this you might not fully take advantage of the features of django. But if you still want to proceed maybe you can use the managed option for models. https://docs.djangoproject.com/en/2.1/ref/models/options/#managed.

with this approach, you'll create the database tables manually first OUTSIDE of django, then connect django to it afterwards. I haven't tried it before but this might be what you need.

also if your teacher requires to perform raw sql queries rather than use the ORM, there is an option to use raw sql queries. https://docs.djangoproject.com/en/2.1/topics/db/sql/#executing-custom-sql-directly

On Thursday, March 28, 2019 at 6:16:54 AM UTC+8, Eric Pascual wrote:
Hi,

Not sure Django is the right choice in your case since one of its main purposes is to hide the SQL stuff by putting the ORM in front. 

You'd better use Flask, Tornado or any other Web framework which does not come with any special feature WRT data access.

Best

Eric


From: django...@googlegroups.com <django...@googlegroups.com> on behalf of cameron hochbrg <caos...@gmail.com>
Sent: Tuesday, March 26, 2019 21:36
To: Django users
Subject: Create models using raw SQL queries
 
hello,

for a project for a database class, we wanted to create a web app using django. However, our teacher wants us to use raw SQL queries for everything involving the database. As such I was wondering if it was possible to create mdoels using raw SQL queries.

thank you in advance

--
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 post to this group, send email to djang...@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/8145efe7-c169-43d6-86e6-e0d64415a764%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+unsubscribe@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/3a449e4d-12fe-48bb-bdf3-45a6d6a5203e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment