I'm reposting this because I was told my last post got lost in an existing 
thread. Sorry about that.

I figured out my syncdb question. It turns out that as long as the model is
defined correctly things go well. And the output from syncdb will help you
with any trivial troubles you might have with your model. Nice!

Another question for you all.

I want to duplicate the queries that the existing app does. The site 
maintains the results, standings, and stats for a baseball league.
It has queries like:

select number, name, win, loss, tie, streak, streak_type,
win/(win+loss+tie)*1.000 wpct, win*2+tie points, win+loss+tie GP,
gamesinseason.games - (win+loss+tie) GL from stand_overall, gamesinseason,
team where team.year = %s && gamesinseason.year = team.year &&
stand_overall.team = team.ID order by points desc, win desc, tie desc, loss

and

select First_name, Last_name, sum(ab) ab, sum(runs) r, sum(1b) s, s
um(2b) d, sum(3b) t, sum(hr) hr, sum(hbp) hbp, sum(bb) bb, sum(ko) ko,
sum(1b+2b+3b+hr) hits, (sum(1b)+sum(2b)+sum(3b)+sum(hr))/sum(ab)*1.0000 avg,
sum(bb)/(sum(bb)+sum(ab))*1.0000 bb,
(sum(1b)+sum(2b)+sum(3b)+sum(hr)+sum(bb)+sum(hbp))/(sum(ab)+sum(bb)+sum(hbp))*1.0000
ob, (sum(1b)+2*sum(2b)+3*sum(3b)+4*sum(hr))/sum(ab)*1.0000 as slug,
sum(runs)/(sum(1b)+sum(2b)+sum(3b)+sum(hr)+sum(bb)+sum(hbp))*1
.0000 score, sum(ko)/(sum(ab)+sum(bb)+sum(hbp))*1.0000 kperapp from player,
offensive_stats, game where player.ID = offensive_stats.player && game.ID =
offensive_stats.game && player.First_name = %s && player.Last_name = %s 
group by First_name, Last_name

My question revolves around how I should get similar results in django. From
what I can tell I should be subclassing a Manager so I can return my own
QuerySets. I don't think the writing custom SQL with connection.cursor() is
the way to go.

I know that the join portions of the where clauses will be taken care of by 
the db_api. I also know that I can do ORDER BY and LIMIT type stuff with 
extra=, .order(), etc.

Am I on the right path?

-- 
| Jason Murray
  --
| The problem in living with popular culture is maintaining some degree of
| individuality - some sense of who we are and what we think in a world
| in which so many others are trying to determine those things for us.
  -- Gary Bauslaugh

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to