Thanks, but that is for SQLAlchemy and we are already using constructions like that. That is not a problem at all. Problem is in Alembic migration – how to correctly get a reflected Table object from the database just being migrated? Something like:
table = Table("some_table", md) where md is the actual reflected metadata of the existing schema in the database that the migration will be also upgrading. s. On Tuesday, September 30, 2014 5:35:20 PM UTC-4, Michael Bayer wrote: > > we have a recipe for that at: > https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/Views > > > On Sep 30, 2014, at 11:03 AM, Stefan Urbanek <stefan....@gmail.com > <javascript:>> wrote: > > I want to construct SELECT from the underlying table(s) to create the view > during the migration. The materialized VIEW is the target object to be > created by the migration. > > Stefan > > On Friday, September 26, 2014 5:34:52 PM UTC-4, Michael Bayer wrote: >> >> not sure if i understand the question. where’s the reflected table >> here? are you trying to reflect the underlying SELECT from it, or make a >> new SELECT out of an existing view ? >> >> if the question is, “I want to reflect a materialized view in >> Postgresql”, we just added that in 1.0, so is not released yet: >> http://docs.sqlalchemy.org/en/latest/changelog/migration_10.html#postgresql-dialect-reflects-materialized-views-foreign-tables >> >> >> >> >> >> >> On Sep 23, 2014, at 11:01 AM, Stefan Urbanek <stefan....@gmail.com> >> wrote: >> >> Hi, >> >> We are trying to create a materialized view (PostgreSQL). We have this >> simple statement compiler: >> >> class CreateMaterializedView(Executable, ClauseElement): >> def __init__(self, name, select): >> self.name = name >> self.select = select >> >> @compiles(CreateMaterializedView) >> def visit_create_materialized_view(element, compiler, **kw): >> >> return "CREATE MATERIALIZED VIEW {} AS {}".format( >> element.name, >> compiler.process(element.select, literal_binds=True) >> ) >> >> >> What is the clean way to get the actual reflected metadata (Table object) >> to construct the `select` element for the CreateMaterializedView? >> >> Thanks, >> >> Stefan >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy-alembic" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to sqlalchemy-alembic+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy-alembic" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy-alembic+unsubscr...@googlegroups.com <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.