I think I got it.

metadata = MetaData()
insp = reflection.Inspector.from_engine(engine)
for table_name in insp.get_table_names(self.db_schema):
    columns = [col['name'] for col in insp.get_columns(table_name, self.
db_schema) if not isinstance(col['type'], IMAGE)]
    Table(table_name, metadata, autoload=True, autoload_with=engine, 
include_columns=columns)

Base = automap_base(metadata=metadata)
Base.prepare()


It's bit pain that reflection is done twice (first inspector then by 
autoload in Table), but it does the job without ripping off SQLAlchemy 
code. 
Maybe if Table could accept output of insp.reflecttable it would be a way 
to ease that.

Zzzeek, what do you think about it? Does it make sense?



On Thursday, December 10, 2015 at 10:57:03 AM UTC+1, mdob wrote:
>
> metadata = MetaData()
> metadata.reflect(engine)
>
> Base = automap_base(metadata=metadata)
> Base.prepare()
>
>
> That did a real nice job but I wanted to skip some columns from being 
> mapped (binary types actually at the moment)
> I see metadata.tables['TableName'].columns to be ImmutableColumnCollection 
> so there's probably no way to exclude column after reflect
>
> Is there a way to skip some columns from being reflected?
>
> Other option I can think of is
>
> insp = reflection.Inspector.from_engine(engine)
> and do the mapping to declarative manually. 
>
> Any thoughts on that?
>
>
>
>
>

-- 
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/d/optout.

Reply via email to