Re: [sqlalchemy] mapper could not assemble primary key for table

2013-07-27 Thread Michael Bayer

On Jul 24, 2013, at 12:13 PM, Dennis Backhaus backha...@moxieinformatics.com 
wrote:

 I have following table:
 
 class Group(DeclarativeBase):
 
 Group definition
 
 Only the ``group_name`` column is required.
 
 
 
 __tablename__ = 'tg_group'
 
 id = Column(Integer, autoincrement=True, primary_key=True)
 group_name = Column(Unicode(16), unique=True, nullable=False)
 display_name = Column(Unicode(255))
 created = Column(DateTime, default=datetime.now)
 users = relation('User', secondary=user_group_table, backref='groups')
 
 
 'id' used to be 'group_id'. I am using TGII and just wrote a migration script 
 to change the 'group_id' field to 'id'. I then manually went into class 
 (above) and changed it to 'id' as well.
 
 Now upon running my project, I get following error message:
 
 sqlalchemy.exc.ArgumentError: Mapper Mapper|Group|tg_group could not assemble 
 any primary key columns for mapped table 'tg_group'
 
 I am at a loss as to why this is happening. I changed all the references to 
 the 'group_id' field to 'id'. Googl'ing this error often comes with a 
 solution that some table does not have a primary key, but I do not see how 
 this could be the case here - as I clearly state 'primary_key = True' for the 
 'id' field.
 
 Can anyone please help me with the trouble shooting?

do you have any errant commas or anything in your actual code, such that it is 
not recognizing the id attribute?   this sounds like something typographical.


 
 -- 
 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.
  
  

-- 
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.




[sqlalchemy] mapper could not assemble primary key for table

2013-07-26 Thread Dennis Backhaus
I have following table:

class Group(DeclarativeBase):

Group definition

Only the ``group_name`` column is required.



__tablename__ = 'tg_group'

id = Column(Integer, autoincrement=True, primary_key=True)
group_name = Column(Unicode(16), unique=True, nullable=False)
display_name = Column(Unicode(255))
created = Column(DateTime, default=datetime.now)
users = relation('User', secondary=user_group_table, backref='groups')


'id' used to be 'group_id'. I am using TGII and just wrote a migration 
script to change the 'group_id' field to 'id'. I then manually went into 
class (above) and changed it to 'id' as well.

Now upon running my project, I get following error message:

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

I am at a loss as to why this is happening. I changed all the references to 
the 'group_id' field to 'id'. Googl'ing this error often comes with a 
solution that some table does not have a primary key, but I do not see how 
this could be the case here - as I clearly state 'primary_key = True' for 
the 'id' field.

Can anyone please help me with the trouble shooting?

-- 
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.