On 12/10/2015 08:06 AM, mdob wrote:
> I think I got it.
> 
> |
> ||metadata =MetaData()
> ||insp =reflection.Inspector.from_engine(engine)
> fortable_name ininsp.get_table_names(self.db_schema):
>     columns =[col['name']forcol
> ininsp.get_columns(table_name,self.db_schema)ifnotisinstance(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.

there's a column_reflect event:

http://docs.sqlalchemy.org/en/rel_1_0/core/events.html?highlight=column_reflect#sqlalchemy.events.DDLEvents.column_reflect

but it does not currently have an option to cause the reflection to skip
the target column (that could be doable).

There's also an exclude_columns argument for Table which should be
easier to use here since you're doing an exclude, not include.


> Maybe if Table could accept output of insp.reflecttable it would be a
> way to ease that.

you can do that.  Take your Inspector object and just run
inspector.reflecttable(your_table, None).  Whatever info it has already
loaded was cached.   But you'll note that reflection also loads up
constraints and indexes so there's a lot more SQL to go for reflection.



> 
> 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 [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to