On 4/28/2010 11:31 PM, Mark wrote:
Hi guys,

I have the following Table construction:

     ADMIN_TABLE = Table('admin',
                         bound_meta_data,
                         Column('username', types.VARCHAR(100),
primary_key=True),
                         autoload=True, schema=schema)

and a mapper as such:

         mapper(Admin, TABLES.ADMIN_TABLE,
                properties={'employee':
                            relation(Employee, primaryjoin=

TABLES.ALL_EMPLOYEES_TABLE.c.employee_id==\
                                     TABLES.ADMIN_TABLE.c.employee_id,

foreign_keys=[TABLES.ADMIN_TABLE.c.employee_id],
                                     backref=backref('user',
foreign_keys=

[TABLES.ADMIN_TABLE.c.employee_id],
                                                     lazy="dynamic")
                                     )
                            },
                extension = VerificationMapper()
            )
When I run paster serve --reload development.ini in my Pylons app, I
get an irritating error complaining the following:

sqlalchemy.exc.ArgumentError: Mapper Mapper|Admin|admin could not
assemble any primary key columns for mapped table 'admin'

As you can see above, I have already mapped the primary_key=True
property, why is it still complaining that it can't find the primary
key?  With this error, I tried out something else, adding the code
below to my mapper configuration:

primary_key=[TABLES.ADMIN_TABLE.columns.username]

Adding this, allowed me to run the server properly, however, when I
query the database, it claims that it is unable to locate the username
column.  I am very sure my database is correct and this is definitely
an issue with my SQLAlchemy code.

Can someone please explain what's going on?  Why do I get the
exception?  Thanks.

This is just a guess I'm afraid, but could it be the autoload=True you're 
passing to the admin Table constructor?  From the docs:

"Usually there will be no Column objects in the constructor if this property is 
set."

Do you really mean to reflect everything _except_ the username column?

Lance

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to