Hi,

I am using alembic to apply a migration for a postgresql view using an *async 
*engine.
I can see this successfully applied in the database.

I have the following declarative mapped class to  the view, defined as:





*class MailingListView(Base):     """View for mailing labels.    After 
metata reflection from db -> model expecting columns to    be available on 
this class.     """*
*    __tablename__ = "mailing_list_view"*



*    # Specify the column override from the underlying view that is the 
primary key    id = Column(UUID(as_uuid=True), primary_key=True)    *









*    # Expecting  these columns  below to be mapped in this class after    
# metadata reflection. Currently have to uncomment these    # to manually 
synchronise with view!    #    # addressee = Column(String)    # street = 
Column(String)    # town = Column(String)    # county = Column(String)    # 
postcode = Column(String)    # cursor = Column(String)*

I am reflecting the views using the following:

     






* def use_inspector(conn):            inspector = inspect(conn)            
return inspector.get_view_names()        views = await 
connection.run_sync(use_inspector)        # I can see the table columns in 
__table__.c.keys()        # after the reflection below has run*
*        await connection.run_sync(*
*            target_metadata.reflect,*
*            only=views,*
*            views=True,*
*            extend_existing=True,*
*        )*

After performing the above reflection I can see that my mapped model has 
the underlyingtable columns updated with those defined in the underlying 
view.



*obj = MailingListView()obj.__table__.c.keys()*
However, the properties of my mapped class are not updated after 
reflection, raising an exception:



*obj = MailingListView()obj.town = "town" # this raises an exception with 
unavailable property*
How is it possible for a postgresql db (asyncpg) + async sqlalchemy to:

Synchronise the columns of a declarative model with its underlying table 
after metadata reflection. Currently, I have to manually specify the 
columns in the declarative model.


-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/0e17cc45-f531-4f86-8c1c-db9ae903ad03n%40googlegroups.com.

Reply via email to