Could not assemble any primary key columns for mapped table error for views

176 views
Skip to first unread message

Andreas Jung

unread,
Apr 23, 2007, 1:23:40 PM4/23/07
to sqlal...@googlegroups.com
I have a view arbeitsmittelhierarchy_arbeitsmittle_view which is defined
as a left join of two tables. Trying to generate a mapper from the autoload
view as Table() fails:

File "build/bdist.linux-i686/egg/sqlalchemy/orm/session.py", line 277, in
query
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 1838, in
class_mapper
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 321, in
compile
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 336, in
_compile_all
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 363, in
_do_compile
File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 518, in
_compile_tables
sqlalchemy.exceptions.ArgumentError: Could not assemble any primary key
columns for mapped table 'arbeitsmittelhierarchy_arbeitsmittel_view'

What is the workaround to deal with such views? Creating a
PrimaryKeyConstraint for the view?

Andreas

Michael Bayer

unread,
Apr 23, 2007, 2:21:24 PM4/23/07
to sqlal...@googlegroups.com

specify primary_key=[cols] to your mapper().

Reply all
Reply to author
Forward
0 new messages