Inserting values into inherited table not working showing the parent table attribute not present in the child table.

22 views
Skip to first unread message

Balu krishnan

unread,
Nov 15, 2019, 12:22:20 AM11/15/19
to sqlalchemy
Hi Friends,

I am new to SQLAlchemy and trying to do with the inheriting property ( from using postgresql_inherits ).
Code for creating a table and insert table is showing below,

models.py


Parent_Table = sqlalchemy.Table(
    "Parent_Table",
    metadata,
    sqlalchemy.Column("Name", sqlalchemy.String),
    sqlalchemy.Column("Description", sqlalchemy.String),
)

Child_Table = sqlalchemy.Table(
    "Child_Table",
    metadata,
sqlalchemy.Column("Extra_col", sqlalchemy.String),
    postgresql_inherits=('Parent_Table')
)
 

 views.py



async def createPolicy(request):
    query = models.Blueprint.insert().values(
    Name = "Bk",
    Description = "testing SQLA",
    Extra_col = "this for write something"
    )
    await models.database.execute(query)


This will show an error

sqlalchemy.exc.CompileError: Unconsumed column names: Name, Description


checked in many sites including SQLA documentation but didn't get a way to do this. Please help.


 
Reply all
Reply to author
Forward
0 new messages