I'm updating my code to work with 0.7.4; and I have a class that is
derived from two tables. I'm looking at
<http://www.sqlalchemy.org/docs/orm/mapper_config.html#mapping-a-class-against-multiple-tables> but I'm not having any luck. When I try to operate on the database the first time it dies with an exception ending in
-
sqlalchemy.exc.InvalidRequestError: One or more mappers failed to
initialize - can't proceed with initialization of other mappers.
Original exception was: Class <class
'coils.foundation.alchemy.task.TaskAction'> does not have a mapped
column named 'job_id
Which I guess I just don't understand. Any pointers would be appreciated
from base import Base, KVC, metadata
from sqlalchemy import *
import sqlalchemy.orm as orm
history_table = Table( 'job_history', metadata,
Column('job_history_id', Integer,
Sequence('key_generator'), primary_key=True),
Column('job_id', Integer),
Column('actor_id', Integer,
ForeignKey(Contact.object_id), nullable=False),
Column('action', String),
Column('action_date', UTCDateTime),
Column('job_status', String),
Column('db_status', String) )
info_table = Table( 'job_history_info', metadata,
Column('job_history_info_id', Integer,
Sequence('key_generator'), primary_key=True),
Column('comment', String),
Column('job_history_id', Integer,
ForeignKey('job_history.job_history_id')),
Column('db_status', String) )
history_and_info = join(history_table, info_table)
class TaskAction(Base, KVC):
""" An OpenGroupare Task History Info entry """
__table__ = history_and_info
db_status = orm.column_property(history_table.c.db_status,
info_table.c.db_status)
object_id =
orm.column_property(history_table.c.job_history_id,
info_table.c.job_history_id)
task_id = history_table.c.job_id
task_status = history_table.c.job_status
action_date = history_table.c.action_date
actor_id = history_table.c.actor_id
comment = info_table.c.comment
Full Exception
====================
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/session.py", line 969, in
query
return self._query_cls(entities, self, **kwargs)
File
"/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py", line 107, in
__init__
self._set_entities(entities)
File
"/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py", line 116, in
_set_entities
self._setup_aliasizers(self._entities)
File
"/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py", line 131, in
_setup_aliasizers
_entity_info(entity)
File
"/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/util.py", line 550, in
_entity_info
mapperlib.configure_mappers()
File
"/usr/local/lib/python2.7/site-packages/SQLAlchemy-0.7.4-py2.7-linux-x86_64.egg/sqlalchemy/orm/mapper.py", line 2858, in
configure_mappers
raise e
sqlalchemy.exc.InvalidRequestError: One or more mappers failed to
initialize - can't proceed with initialization of other mappers.
Original exception was: Class <class
'coils.foundation.alchemy.task.TaskAction'> does not have a mapped
column named 'job_id
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.