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

Jeffrey D Peterson bgpete at gmail.com
Thu Jan 14 11:52:32 EST 2010


> A bit I'm confused about is that you say SA can't reflect views but
> you're still using rdb.reflected().
> 
> If we had a spelling for rdb.dontcreate() (rdb.evolve is way too cute
> in
> my mind - and confusing, as people will think about schema evolution),
> would that be sufficient for you to stop using rdb.reflected() or would
> you still need it?
> 
> Concerning spelling, I see you use 'useexisting', which is a SQLAlchemy
> feature, correct? Perhaps the spelling should be 'rdb.useexisting'. In
> this case it'll always try to use an existing table and never try to
> create it.

Ok, more insight...

We actually have a few things going on depending on implementation:

With Tables (w/PK):

	rdb.reflected() is as you expect.

	When overriding:

		rdb.reflected() and useexisting are required when not
overriding all columns 
		neither is required if you do

	create_all is able to check the DB and find the table and not try
and create it.


With Tables (w/o/PK):

	rdb.reflected() fails complaining about PK, requiring you to
override.

	When overriding:

		rdb.reflected() and useexisting are required when not
overriding all columns 
		neither is required if you do

	create_all is able to check the DB and find the table and not try
and create it.


The patterns are similar if you are overriding just because you want to
(regardless of PK)


With Views:

	rdb.reflected() fails complaining about PK, requiring you to
override.

	When overriding:

		rdb.reflected() and useexisting are required when not
overriding all columns 
		neither is required if you do


	apparently when create_all checks for existing it cannot identify
the view, therefore it tries to create it requiring it to be pulled from the
metadata.


So my statement about the PK issue is true but only part of the story.

That being said use_existing may not be what we want either, maybe we want
rdb.override() and possibly rdb.override_view() and maybe those take a
Boolean argument full which when True skips rdb.reflected() and
use_existing, but when False includes them?  Maybe defaulting to False as it
seems to me you'd want to reflect as much as possible.

Thoughts?


Regards,

Jeff Peterson
Webmaster
Crary Industries



More information about the Grok-dev mailing list