Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - python sql query in django

 
Thread Tools Search this Thread
Old 02-24-2009, 09:13 PM   #11
Default Re: python sql query in django


On Feb 24, 10:36*am, "Diez B. Roggisch" <de...@nospam.web.de> wrote:
> > Thanks for all your suggestions. *From what I've experienced in Django
> > and now that I know a little more about how Python functions, I will
> > probably use a combination of PHP and Django, instead of trying to get
> > Python to do the web portion of my project. *Thanks again!

>
> That sounds like the worst idea. Django's ORM is good when used from
> within django, because of all the additional goodies like the admin
> interface.
>
> But if you are going to do the webfrontend using PHP, what part is left
> for django? If it's only the ORM (for whatever you still use that
> anyway), there are better alternatives - SQLAlchemy, and SQLObject, for
> Python. They are more powerful and not interwoven with django.
>
> If you are going to hand-code the interface in PHP, I fail to see though
> why you don't do that in Django directly. You are not forced to use the
> Admin-interface.
>
> Diez


Hello Diez,

I think Django is fabulous for the admin-interface, a simple text
search and template inheritance. I will use Django for all of those.
What I'm not getting an answer to and cannot find an example of is a
complex search, where I have to retrieve data from multiple tables,
combine the data, remove the duplicates, etc between a web page and
the database. The code that started this thread is only a small piece
of the complex data retrieval I need to do. PHP is great for writing
complex SQL queries right in the HTML template and I know exactly what
it is doing.


May
  Reply With Quote
Old 02-25-2009, 08:48 PM   #12
Bruno Desthuilliers
 
Posts: n/a
Default Re: python sql query in django
May a écrit :
> On Feb 24, 10:36 am, "Diez B. Roggisch" <de...@nospam.web.de> wrote:
>>> Thanks for all your suggestions. From what I've experienced in Django
>>> and now that I know a little more about how Python functions, I will
>>> probably use a combination of PHP and Django, instead of trying to get
>>> Python to do the web portion of my project. Thanks again!

>> That sounds like the worst idea. Django's ORM is good when used from
>> within django, because of all the additional goodies like the admin
>> interface.
>>
>> But if you are going to do the webfrontend using PHP, what part is left
>> for django? If it's only the ORM (for whatever you still use that
>> anyway), there are better alternatives - SQLAlchemy, and SQLObject, for
>> Python. They are more powerful and not interwoven with django.
>>
>> If you are going to hand-code the interface in PHP, I fail to see though
>> why you don't do that in Django directly. You are not forced to use the
>> Admin-interface.
>>
>> Diez

>
> Hello Diez,
>
> I think Django is fabulous for the admin-interface, a simple text
> search and template inheritance.


And I think you really don't get what Django is good for.

> I will use Django for all of those.
> What I'm not getting an answer to and cannot find an example of is a
> complex search, where I have to retrieve data from multiple tables,
> combine the data, remove the duplicates, etc


Django's ORM is mostly a wrapper above the db-api. It's intended to make
most common db access a no-brainer, not to replace full-blown SQL for
complex things. Now the good news is that you *still* can drop to a
lower raw-sql level - the one you'd get using either PHP or Python's
db-api - for more complex things. IOW, PHP won't buy you anything here.

> The code that started this thread is only a small piece
> of the complex data retrieval I need to do.


The "code that started this thread" is a total no-brainer using Django
(as you would know by now if you had reposted your question on django's
group - or even just read the FineManual, where this use case is fully
documented), and doesn't even require going down to raw sql.

> PHP is great for writing
> complex SQL queries right in the HTML template


What the .... a complex SQL query has to do in a template anyway ???
Sorry, but what you're saying here is that PHP is great for writing
unmaintainable spaghetti code. FWIW, even PHP coders are trying to get
out of this kind of mess nowadays.



Bruno Desthuilliers
  Reply With Quote
Old 02-25-2009, 11:12 PM   #13
Diez B. Roggisch
 
Posts: n/a
Default Re: python sql query in django
> I think Django is fabulous for the admin-interface, a simple text
> search and template inheritance. I will use Django for all of those.
> What I'm not getting an answer to and cannot find an example of is a
> complex search, where I have to retrieve data from multiple tables,
> combine the data, remove the duplicates, etc between a web page and
> the database. The code that started this thread is only a small piece
> of the complex data retrieval I need to do. PHP is great for writing
> complex SQL queries right in the HTML template and I know exactly what
> it is doing.


First of all, mixing technologies without need is most of the times a
bad idea - so if it is really the case that you can't solve all of your
issues in django, you shouldn't use it at all, but solve them in PHP.


But to be honest - I doubt that django isn't capable of solving your
problem.

See

http://docs.djangoproject.com/en/dev...ics-db-queries

for a introduction to the multitude of query-options. I doubt that your
rather simple m:n-relationship is covered there.


I myself use SQLAlchemy, and that can for sure query and filter those
relationships.

Diez


Diez B. Roggisch
  Reply With Quote
Old 02-25-2009, 11:14 PM   #14
Diez B. Roggisch
 
Posts: n/a
Default Re: python sql query in django

> for a introduction to the multitude of query-options. I doubt that your
> rather simple m:n-relationship is covered there.


s/is/isn't/

Diez



Diez B. Roggisch
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Prerequisites 70-745 (Business Intelligence) Valmont MCITP 3 06-24-2008 03:03 PM
SQL Server 2008 delayed into Q3 2008 darrilgibson@cox.net MCITP 0 01-27-2008 10:26 PM
MCITP SQL Server 2005 or SQL Server 2008 Darrilgibson@gmail.com MCITP 0 12-19-2007 01:56 PM
SQL 2008 upgrade exam? JFoushee MCITP 4 12-12-2007 12:10 AM
SQL Server 2005 Migration Assistant Autonumber problem. LarryWestMCSD MCTS 1 03-28-2007 02:08 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46