On 9/7/06, Enrico Morelli <[EMAIL PROTECTED]> wrote: > 1) during the definition of the plan table I receive the error: > non-keyword arg after keyword arg > To correct it I have to put primary_key=True after the ForeignKey > definition, is it correct?
Correct - I didn't test the code I sent, sorry. > 2) I'm trying to put some data on the db. But I don't understand > how to put a new instrument in the plain table. > > If I do: > i=session.query(Instrument).get(1) > p=PlanEntry() > p.day=1 > p.year=2006 > p.month=9 > p.instrument.append(i) or p.instrument.append(Instrument(i)) p.instrument = i should do it. > I raise an exception: 'str' object has no attribute 'append' I don't know why p.instrument is a str, should be either None or an instance of Instrument. Can someone verify that I'm not misleading Enrico here? Arnar > On Wed, 6 Sep 2006 15:34:50 +0000 > "Arnar Birgisson" <[EMAIL PROTECTED]> wrote: > > > You could do something like this: > > > > instruments=Table('instruments', metadata, > > Column('instrument_id', Integer, primary_key=True), > > Column('name', String)) > > > > plan=Table('plan', metadata, > > Column('year', Integer, primary_key=True), > > Column('month', Integer, primary_key=True), > > Column('day', Integer, primary_key=True), > > Column('instrument_id', Integer, primary_key=True, > > ForeignKey('instruments.instrument_id')), > > Column('data', String)) > > > > class PlanEntry: pass > > class Instrument: pass > > > > mapper(Instrument, instruments) > > mapper(PlanEntry, plan, properties={ > > 'instrument': relation(Instrument) > > }) > > > > -- > ------------------------------------------------------------------- > (o_ > (o_ //\ Coltivate Linux che tanto Windows si pianta da solo. > (/)_ V_/_ > +------------------------------------------------------------------+ > | ENRICO MORELLI | email: [EMAIL PROTECTED] | > | * * * * | phone: +39 055 4574269 | > | University of Florence | fax : +39 055 4574253 | > | CERM - via Sacconi, 6 - 50019 Sesto Fiorentino (FI) - ITALY | > +------------------------------------------------------------------+ > ------------------------------------------------------------------------- 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 Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users