This approach still doesn't seem to help me.  I get the same error, just
about type School:

2014-02-08 11:33:59,109 INFO sqlalchemy.engine.base.Engine ROLLBACK
(ProgrammingError) can't adapt type 'School' 'INSERT INTO site (name,
address1, address2, postcode, city, fk_country_id, fk_school_id) VALUES
(%(name)s, %(address1)s, %(address2)s, %(postcode)s, %(city)s,
%(fk_country_id)s, %(fk_school_id)s) RETURNING site.id' {'city':
u'Carddif', 'fk_school_id': <warrior.models.location.School object at
0x9abcf8c>, 'name': u'Choo Site', 'address1': u'1 Choo Way', 'address2':
u'', 'postcode': u'12345', 'fk_country_id': u'1'}

How can I use relationships to do this?  If I do:

school = School()
site = Site()
site.fk_school_id = school

I get the above error.  If I change school to school.id I get the
InstrumentedAttribute error again.

How to do this without doing multiple commits?

On 5 February 2014 22:34, Matthew Phipps <matt.the.m...@gmail.com> wrote:

>
> On Wednesday, February 5, 2014 10:44:39 AM UTC-5, Michael Bayer wrote:
>
>>
>> On Feb 5, 2014, at 9:43 AM, Jude Lucien <jlu...@gmail.com> wrote:
>>
>> I have a secondary problem now having changed my model to use declarative
>> base - as in db.create_all() does not create my tables in the database.
>>
>> How can I do this using the declarative base method?
>>
>>
>> Base.metadata is where you'd call create_all(my engine) from.
>>
>>
> @Jude: db.create_all() is part of the Flask-SQLAlchemy API, not SQLAlchemy
> proper. AFAIK it's ok to mix the two together (the project I'm working on
> certainly does) but if you're not subclassing db.Model in your models
> Flask-SQLAlchemy may not be doing you much good. Which is fine, just be
> aware.
>
> -Matt
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sqlalchemy" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sqlalchemy/yl_5BnwzfhA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> sqlalchemy+unsubscr...@googlegroups.com.
>
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
"None are more hopelessly enslaved than those who falsely believe they are
free"  -- Johann Wolfgang von Goethe

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to