Re: [Sqlalchemy-users] many-to-many relation newbie question

2006-09-04 Thread Enrico Morelli
On Mon, 4 Sep 2006 16:21:33 +0200 Enrico Morelli <[EMAIL PROTECTED]> wrote: > On Mon, 04 Sep 2006 15:51:06 +0200 > Sol <[EMAIL PROTECTED]> wrote: > > > Hello, not sure if i got you right, but here is what i think. > > > > > users_projects=Table('users_projects', metadata, > > > Column('id_us

Re: [Sqlalchemy-users] many-to-many relation newbie question

2006-09-04 Thread Enrico Morelli
On Mon, 4 Sep 2006 16:39:18 +0200 Enrico Morelli <[EMAIL PROTECTED]> wrote: > On Mon, 4 Sep 2006 16:34:40 +0200 > Enrico Morelli <[EMAIL PROTECTED]> wrote: > > > On Mon, 4 Sep 2006 16:07:51 +0200 > > "Andrija Zaric" <[EMAIL PROTECTED]> wrote: > > > > > If you are going to do script once and outs

Re: [Sqlalchemy-users] many-to-many relation newbie question

2006-09-04 Thread Enrico Morelli
On Mon, 4 Sep 2006 16:34:40 +0200 Enrico Morelli <[EMAIL PROTECTED]> wrote: > On Mon, 4 Sep 2006 16:07:51 +0200 > "Andrija Zaric" <[EMAIL PROTECTED]> wrote: > > > If you are going to do script once and outside main application, > > maybe this is going to be little faster: > > > > users = session

Re: [Sqlalchemy-users] many-to-many relation newbie question

2006-09-04 Thread Enrico Morelli
On Mon, 4 Sep 2006 16:07:51 +0200 "Andrija Zaric" <[EMAIL PROTECTED]> wrote: > If you are going to do script once and outside main application, maybe > this is going to be little faster: > > users = session.query(Users).select() > > ref_pairs = [] > for u in users: > ref_pairs.extend([(u.id,

Re: [Sqlalchemy-users] many-to-many relation newbie question

2006-09-04 Thread Enrico Morelli
On Mon, 04 Sep 2006 15:51:06 +0200 Sol <[EMAIL PROTECTED]> wrote: > 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, > > Fo

Re: [Sqlalchemy-users] many-to-many relation newbie question

2006-09-04 Thread Andrija Zaric
If you are going to do script once and outside main application, maybe this is going to be little faster: users = session.query(Users).select() ref_pairs = [] for u in users: ref_pairs.extend([(u.id, int(pr_id)) for pr_id in u.fk_project.split(',')]) #this should do multi-value insert: users

Re: [Sqlalchemy-users] many-to-many relation newbie question

2006-09-04 Thread Sol
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() > > cl

[Sqlalchemy-users] many-to-many relation newbie question

2006-09-04 Thread Enrico Morelli
Dear all, I have a question regards many-to-many relationship. I have the following script: from sqlalchemy import * engine=create_engine("postgres://[EMAIL PROTECTED]/NMR2") metadata=BoundMetaData(engine) session=create_session() users=Table('users', metadata, autoload=True) projects=Table('pr