Thanks again for your support.
I'm afraid to disturb you again, I promise that is the last time
(I hope ;-)))
Only two things.
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?
The table description after it creation is:
year | integer | not null default nextval('plan_year_seq'::regclass)
month | integer | not null default nextval('plan_month_seq'::regclass)
day | integer | not null default nextval('plan_day_seq'::regclass)
instrument_id | integer | not null
data | text |
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))
I raise an exception: 'str' object has no attribute 'append'
(i.name and i.instrument_id exists).
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users