[Grok-dev] megrok.rdb, Oracle, and views.

Martijn Faassen faassen at startifact.com
Tue Jan 12 16:28:35 EST 2010

Hey there,

Jeffrey D Peterson wrote:
> I have it all working except for my most important use case, 
> “reflecting” views.  Now that terminology is weak since you can’t
> really reflect a view.  You can, however, define the view as a class
> using Table(), defining the columns, and declaring a PK etc.  What
> you don’t want to do in this case is create the table, which is
> exactly what megrok.rdb tries to do by default.

Just to get the terminology straight, you are talking about reflecting
relational views, not Grok views, correct?

I'm indeed a bit confused by your use of the term 'reflected'. If you
were to use grok.reflected() on the grok.Model that stands for the view,
it shouldn't try to create anything at all. So presumably you're not
doing that.

> Is there some configuration flag or parameter to only map the class
> and not go ahead and create the tables?  Maybe something to pass to 
> __table_args__ like with “schema”.

megrok.rdb as far as I can think of it right now supports two "modes":

* models which create the underlying database table if it isn't there yet.

* models which are reflected from the underlying database table. The 
SQLAlchemy table is created from the reflected information.

You have a third case, if I understand you correctly:

* a model which is associated manually to a SQLAlchemy table and 
shouldn't ever try to create a relational table (as there's none such 
thing anyway).

Your reason to talk about reflection is that with reflection some of 
this already happens: the underlying table is not created as it is 
reflected, and metadata.create_all(), which megrok.rdb uses, will in 
that case already have the relational table available (as it could 
reflect from it). Correct?

I think this means we'd need to modify "createTables" in setup.py in 
megrok.rdb with the possibility to skip creating tables for those 
rdb.Model classes that don't want this.

How would you prefer to spell this on the rdb.Model? rdb.dontcreate() 
looks a bit ugly.



More information about the Grok-dev mailing list