On 4 Jul, 18:03, jrpfinch <[EMAIL PROTECTED]> wrote:
> I have just started using Python and TurboGears with SQLAlchemy and I
> think its great so far.  I am working with an already-created database
> and am wondering what the best way is to represent the relationships
> between the recurring_task and employee_status table:
>
> employee_statuses = Table('employee_status', metadata,
>                         #Column('emp_id', Integer, primary_key=True),
>                         autoload=True)
> recurring_tasks = Table('recurring_task', metadata,
>                         #Column('rt_id', Integer, primary_key=True),
>                         autoload=True)
> class Employee_status(object):
>     pass
> class Recurring_task(object):
>     pass
> employee_status_mapper = mapper(Employee_status, employee_statuses)
> recurring_task_mapper = mapper(Recurring_task, recurring_tasks)
>
> So far, so good - this works in the tg-admin shell.  recurring_task
> has three columns, rt_raiser, rt_owner and rt_status which are all
> instances of employee_status.  I would be grateful if somebody could
> indicate the best way to represent these relationships in the model as
> I'm not sure which of the many examples in the documentation is
> relevant - I am worried because I have one table referencing another
> table multiple times.
>
> Many thanks
>
> Jon

At the moment I am trying

mapper(Recurring_task, recurring_tasks,
            properties = {"raiser":relation(Employee_status,
primaryjoin=(recurring_tasks.c.rt_raiser_id==Employee_status.c.emp_id)})

at the bottom of my model definition.  I hoped this would give
Recurring_task a raiser attribute that I could get all the details of
employee_status from, but all I'm getting so far is:

 File "/tools/rtr-alchemy/rtralchemy/model.py", line 55
    mapper(Recurring_task, recurring_tasks, properties =
{"raiser":relation(Employee_status,
primaryjoin=(recurring_tasks.c.rt_raiser_id==Employee_status.c.emp_id)})
 
^
SyntaxError: invalid syntax

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to