Hello, not sure if i got you right, but here is what i think.
> users_projects=Table('users_projects', metadata,
> Column('id_users', Integer, ForeignKey('users.id_users')),
> Column('id_projects', Integer, ForeignKey('projects.id_projects')),
> )
>
> users_projects.create()
>
> class Users(object):
> pass
> class Projects(object):
> pass
>
> umapper=mapper(Users, users)
umapper = mapper(Users, users, properties = dict(
projects = relation(Projects, secondary = users_projects),
))
> pmapper=mapper(Projects, projects, properties={
> 'users' : relation(Users, secondary=users_projects,
> backref="projects"), }
> )
>
> u=session.query(Users).select()
>
> for i in range(len(u)):
> pr=u[i].fk_project.split(',')
> for p in range(len(pr)-1):
>
> pname=session.query(Projects).selectfirst(projects.c.id_projects==pr[p])
> ????????
all_usuers = session.query(Users).select()
for user in all_users:
project_ids = user.fk_project.split(',')
for project_id in project_ids:
project = session.get(Projects, project_id)
user.projects.append(project)
session.flush()
> Actually, the users table has a fk_project field like 1,15,3,. Each
Now dismiss the fk_project field altogether, you do not need it with
many-to-many relationships.
--
Cheers, Sol.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users