Michael, Thanks for the response and help, I made the change and the class is populated, this is great!
Again, thanks for your help, Doug > -----Original Message----- > From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED] > On Behalf Of Michael Bayer > Sent: Sunday, September 21, 2008 10:41 PM > To: sqlalchemy@googlegroups.com > Subject: [sqlalchemy] Re: ORM mapping existing data tables > > > > On Sep 21, 2008, at 9:09 PM, Doug Farrell wrote: > > > > > Hi everyone, > > > > I'm new to SqlAlchemy, but I've got some things working and really am > > enjoying it. Right now I'm trying to ORM map some existing MySQL > > database tables to a class. I've read the documentation, I guess I'm > > just not getting it. Can someone help me out. I've done this: > > > > # initialize the sqlite engine and SqlAlchemy base objects > > engine = create_engine('mysql://username:@hostname/database', > > echo=True) > > meta = MetaData(engine) > > > > myTable = Table('mytable', meta, autoload=True) > > l = [c.name for c in pressrouting.columns] > > print l > > > > And this works fine, but if I try this: > > > > # initialize the sqlite engine and SqlAlchemy base objects > > engine = create_engine('mysql://username:@hostname/database', > > echo=True) > > meta = MetaData(engine) > > Base = declarative_base(metadata=meta) > > > > class MyTable(Base): > > __tablename__ = "mytable" > > Pass > > > > I get this error: > > > > sqlalchemy.exc.ArgumentError: Mapper Mapper|MyTable|mytable could not > > assemble any primary key columns for mapped table 'mytable' > > > > What is this error message trying to tell me? > > the "autoload=True" part is missing from your second recipe, so the > table has no columns and therefore no primary key either. Add in > __table_args__ = {'autoload':True}. > > > > t this group at http://groups.google.com/group/sqlalchemy?hl=en > -~----------~----~----~----~------~----~------~--~--- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---