Looks like you're on the right track, but there's a few things that
can make your life easier:

1) drop your ID columns (unless you have your own integer IDs that are
meaningful). SQLObjects come with a primary key that is an integer ID.
(just obj.id to access it)

2) check out the sqlobject docs about one-to-many relationships:
http://sqlobject.org/SQLObject.html#one-to-many-relationships

By setting up your relationships, you don't need to run separate
queries... you can just access the lists that SQLObject gives you..

One not really important thing: Python convention would have the class
name be upper case, but the attribute names would be either lowerCase
or lower_case.

Kevin

On 10/26/05, modmans2ndcoming <[EMAIL PROTECTED]> wrote:
>
> ---------------------
> class Player(SQLObject):
>         PlayerID = IntCol(length=10, alternateID=True, default=None)
>         FirstName = StringCol(length=20, default=None)
>         LastName = StringCol(length=30, default=None)
>         Position = StringCol(length=2, default=None)
>         TeamID = IntCol(length=5, default=None)
>         PlayerNum = StringCol(length=3, default=None)
>
> class PStats(SQLObject):
>         PlayerID = IntCol(length=10, alternateID=True, default=None)
>         Year = IntCol(length=4, default=None)
>         Games = FloatCol(length=3)
>         Goals = IntCol(length=3)
>         Assists = IntCol(length=3)
>         Points = IntCol(length=4)
>         PIM = IntCol(length=4)
> class GStats(SQLObject):
>         PlayerID = IntCol(length=10, alternateID=True, default=None)
>         Year = IntCol(length=4, default=None)
>         Games = FloatCol(length=3)
>         Goals = IntCol(length=3)
>         Assists = IntCol(length=3)
>         Points = IntCol(length=4)
>         PIM = IntCol(length=4)
>         Shutouts = IntCol(length=3)
>         GA = FloatCol(length=3)
>         GF = IntCol(length=3)
>         GAA = FloatCol(length=4)
>
> class TStat(SQLObject):
>         TeamID = IntCol(length=5, alternateID=True, default=None)
>         Name = StringCol(Length=20, default=None)
>         Year = IntCol(length=4, default=None)
>         Wins = IntCol(length=3)
>         Lost = IntCol(length=3)
>         Ties = IntCol(length=3)
> --------------------------------
>
> How do I connect the data in these tables?
>
> I want to print the player data and their stats and then the team
> stats.
>
> basically like this right?
>     while not at the end of the DB
>            print player record
>                   print pstat where pstat.PlayerID == player.PlayerID
>                   print Tstat where Tstat.TeamID == player.TeamID
>
> is that the right layout for a join like that?
>
>


--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com

Reply via email to