On Feb 10, 2010, at 6:05 PM, Jeff Peterson wrote:

>  
> It’s touching a ton of tables, hundreds…if I had to guess I’d say every table 
> in the schema.  The reasons for this are unknown to me, certainly all those 
> tables are not related specifically to the single view I am attempting to 
> reflect. 

that shouldn't be possible on a single table reflect, if its a view.  Views 
have no foreign key metadata so it would have no reason to go anywhere else.   
you'd have to provide more specifics in order for us to see how that might be 
reproduced.


>  
> The other thing I am noticing is the code in the lib does this:
>  
>     reflectTables(metadata)
>     createTables(metadata)
>     notify(DatabaseSetupEvent(metadata))
> 
> reflectTables does, among other things, a metadata.reflect(bind=engine)
>  
> createTables looks like:
>  
> def createTables(metadata):
>     """Create class-specified tables.
>     """
>     engine = Engine()
>     metadata.create_all(engine)
>  
>  
> So, the metadata has (or could have) both reflected tables/views and tables 
> needing to be created, which would be fine assuming the reflected class is 
> actually a table in the DB, which we know in this case it isn’t it’s a view 
> and so it tried to create it.  So, the issue is what’s the best solution for 
> stopping this?  Should the reflected views simply be removed from the 
> metadata after reflection? Or is there some simpler answer?

as i said, it makes no sense at all for your web app to be calling create_all() 
when it starts up.   create_all() should only be used when you are initially 
configuring your database or migrating its schema, things that should not 
happen implicitly.

If you must call create_all(), use a separate MetaData object for your 
reflection step.   Its not a good idea to attempt to issue CREATE TABLE for all 
the tables that you've just reflected.






>  
> TIA,
>  
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit 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 sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit 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 sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit 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 sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit 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 sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit 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 sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to