Thanks, this is partially helpful. However, in the example there is:
stuff_view = view("stuff_view"...
and not:
stuff_view = Table("stuff_view"...
My problem is, that I get just a name and expect TABLE or VIEW and I am
replacing TABLE or VIEW with TABLE or VIEW. To be able to replace
something, I need to drop the something. To be able to drop the something,
I need to know how to drop it, therefore I need to know whether it is a
table (DROP TABLE) or a view (DROP VIEW). All I have is just a name. I was
expecting Table() to know whether it is table or a view. I have no problems
with using the solution in the wiki, however I need to know a way, how to
determine whether the something named "stuff_view" is real view or a table
(primitive straightforward materialization of a view).
Is there a way how to know whether the Table() object represents view or
table? Something like my_table.is_view?
Stefan
On Sunday, May 6, 2012 4:50:33 PM UTC+2, Michael Bayer wrote:
>
> there's a recipe for views, including DDL, here:
>
> http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Views
>
> another way to go would be to alter the compilation of
> sqlalchemy.schema.DropTable which would somehow have to check those Table
> objects you have which are actually views, maybe if you put a flag on them
> table.isview=True or something like that.
>
>
>
> On May 6, 2012, at 7:07 AM, Stefan Urbanek wrote:
>
> Hi,
>
> Problem: My code generates a table or a view, based on user's preference.
> Table("something") accepts both table and view name and works properly
> for most of the tasks, including Table.exists(). When I use
> Table.delete()(postgresql) it works only on tables, when I try to use it on a
> view I get:
>
> sqlalchemy.exc.ProgrammingError: (ProgrammingError) "contracts_denorm" is
> not a table
> HINT: Use DROP VIEW to remove a view.
>
> This seems to be a little bit inconsistent or maybe I am missing something
> here and not doing it right. How to properly drop a view using SQLAlchemy?
> As for workaround, is there a way how I can at least determine whether the
> Table object is a view and issue manual DROP VIEW statement by myself?
>
> Stefan Urbanek
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sqlalchemy/-/0aZj0MOWgagJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/1a-_o9LvKrsJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.