Thank you Mike,
That worked great (of course).  Also thank you for the work you've done 
with open source and the incredible support you provide.


On Wednesday, October 12, 2016 at 11:13:28 PM UTC-7, Eric wrote:
> Hi,
> I have a file where I'd like to define all the table classes and 
> then interact with them from my main module file (desktop app).  I am 
> connecting to Postgres 9.5 and have attached another Postgres database on 
> the same server (localhost) with postgres_fdw.  It all appears to be 
> working well, print(insp.get_foreign_table_names()) shows the attached 
> tables.  This is with Python 3.5.2 on Windows 7.
> I am using DeferredReflection so I don't have to have the engine setup in 
> the model file and am connecting to one of the foreign tables:
>     BaseDef = declarative_base(cls=DeferredReflection)
>     class TestTable(BaseDef):
>         __tablename__ = 'test_table'
> and get the error when I run BaseDef.prepare(engine):
> sqlalchemy.exc.ArgumentError: Mapper Mapper|TestTable|test_table could not 
> assemble any primary key columns for mapped table 'test_table'
> I tried:
>     class TestTable(BaseDef):
>         __tablename__ = 'test_table'
>         Column('test_id', Integer, primary_key=True)  # no effect
>     and
>     __mapper_args__ = {
>         'primary_key': (test_table.c.test_id, )}  # attribute error on 
> test_id
> Can I use DeferredReflection and still define the primary key column?
> Also, any issue with defining some of the classes using a normal Base = 
> declarative_base() and some with deferred?  I'm using the normal Base 
> with classes where the full table definition is in the model file.  I'm 
> just starting to work with SQLAlchemy and Postgres after mostly working 
> with SQLite (and I'm a hardware guy).
> Thanks,
> Eric

SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See for a full description.
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 post to this group, send email to
Visit this group at
For more options, visit

Reply via email to