Re: need help with calling following complex query

2011-07-11 Thread Roshan Mathews
On Mon, Jul 11, 2011 at 10:36, Venkatraman S wrote: > Raw-sql and the snippet provided by me would end up generating the same sql. > > One advantage of my snippet is, if your db does not support sin/cos > functions(like sqlite3), > then you can go ahead defining funcs which computes the same. Som

Re: need help with calling following complex query

2011-07-11 Thread Venkatraman S
On Mon, Jul 11, 2011 at 10:36 PM, Jonas Geiregat wrote: > > > > results.extra(select={ > > 'distance': > '(acos(sin(latitude)*sin(%(latitude)f)+cos(latitude)*cos(%(latitude)f)*cos(%(longitude)f-longitude)))' > % { > > 'latitude': latit

Re: need help with calling following complex query

2011-07-11 Thread Venkatraman S
On Tue, Jul 12, 2011 at 4:36 AM, sanket wrote: > Thanks @Venkatraman, I really appreciate your help. > ability to create a function is pretty cool. > Thanks. Actually, i stumbled on this solution due to my use case - i test all my apps in sqlite3 and then move to other dbs; as it is easy for me

Re: need help with calling following complex query

2011-07-11 Thread sanket
Thanks @Venkatraman, I really appreciate your help. ability to create a function is pretty cool. Thanks again, sanket On Jul 11, 1:06 pm, Jonas Geiregat wrote: > > results.extra(select={ > >                             'distance': > > '(acos(sin(latitude)*sin(%(latitude)f)+cos(latitude)*cos(%(l

Re: need help with calling following complex query

2011-07-11 Thread Jonas Geiregat
> > results.extra(select={ > 'distance': > '(acos(sin(latitude)*sin(%(latitude)f)+cos(latitude)*cos(%(latitude)f)*cos(%(longitude)f-longitude)))' > % { > 'latitude': latitude, > 'longitude': longitude

Re: need help with calling following complex query

2011-07-11 Thread Cal Leeming [Simplicity Media Ltd]
Thats pretty cool, I didnt know you could do create function. Will check this out later :) On 11 Jul 2011 06:06, "Venkatraman S" wrote: > On Mon, Jul 11, 2011 at 10:02 AM, sanket wrote: > >> I think I would go ahead with executing the raw SQL in this case. >> The solution by @Venatraman looks int

Re: need help with calling following complex query

2011-07-10 Thread Venkatraman S
On Mon, Jul 11, 2011 at 10:02 AM, sanket wrote: > I think I would go ahead with executing the raw SQL in this case. > The solution by @Venatraman looks interesting too. I would give it a > try. > Raw-sql and the snippet provided by me would end up generating the same sql. One advantage of my sn

Re: need help with calling following complex query

2011-07-10 Thread sanket
Thanks all for the help, I really appreciate it. I think I would go ahead with executing the raw SQL in this case. The solution by @Venatraman looks interesting too. I would give it a try. I might write a stored procedure if I start getting performance issues if data starts growing. Thanks again,

Re: need help with calling following complex query

2011-07-10 Thread Venkatraman S
On Mon, Jul 11, 2011 at 7:10 AM, Cal Leeming [Simplicity Media Ltd] < cal.leem...@simplicitymedialtd.co.uk> wrote: > +1 on raw SQL in this instance. Not exactly, using ORM is pretty easy too. You would do something like this: results.extra(select={ 'distance': '(acos

Re: need help with calling following complex query

2011-07-10 Thread Cal Leeming [Simplicity Media Ltd]
+1 on raw SQL in this instance. On Mon, Jul 11, 2011 at 2:36 AM, Jian Chang wrote: > Using raw sql is a better idea > > > 2011/7/11 Jonas Geiregat > >> >> >> In order to find the places in near by area I want to make following >> mysql query. but I am not sure how should I translate it using dj

Re: need help with calling following complex query

2011-07-10 Thread Jian Chang
Using raw sql is a better idea 2011/7/11 Jonas Geiregat > > > In order to find the places in near by area I want to make following > mysql query. but I am not sure how should I translate it using django > models and managers. > > > You could execute the raw sql query string, see: > https://docs.

Re: need help with calling following complex query

2011-07-10 Thread Jonas Geiregat
> > > In order to find the places in near by area I want to make following > mysql query. but I am not sure how should I translate it using django > models and managers. You could execute the raw sql query string, see: https://docs.djangoproject.com/en/dev/topics/db/sql/ for more information on

need help with calling following complex query

2011-07-10 Thread sanket
Hey All, I am quite new to Django and recently started using django for developing a location based service. In order to find the places in near by area I want to make following mysql query. but I am not sure how should I translate it using django models and managers. orig.lat = x orig.lon = y "