Django multi table inheritance represented with SQLAlchemy -


How can I change the Django's multi-table array schema for a SQLLM model?

It seems like SQLElim is a discriminatory column on the parents table included in the table succession method. There is no such area with Django's multi-table heritage.

CommonParent (models.Model): field = models.CharField (max_length = 10) Category ChildA (Normal): Pass Class ChildB General Reader: Pass < P> This results in 3 tables: child , childbie , and incomplete . Child tables have an automated foreign key which is (parent group name) _ptr . Django uses it to drag the original table columns.

With Django, a child example join occurs on general viewer

code> table and all The fields have been merged into the example of the class.

How do I make this behavior through SQLLE motivational model?

Any sign in the right direction will be very helpful. / P>

Update:

In other words, I need the above Dijena model relationship which can be accessed through SQLLM by calling

  child_b = Use ChildB.query.first () Hetter (child_b, 'field') # field from the original table, `commonprint`  

In the same way, I can do this with Django ORM:

Post-text "itemprop =" text ">

In Dijongo, basically the in There are two ways to present data in CommonParent and ChildA : HildA knows that he has parents in the table for commonmark SQLAlchemy uses a different approach, where Ampak knows that there is a child in the table for his ChildA at the database level you use the method of Django, so that You want to copy into your SQLAlchemy code.

More specifically, in Django, whenever you query for CommonParent , you only receive data related to the CommonParent class , And when you do a query, get a child , one for both of you child and normalcaps through a section clause it happens.

General Area class works well because it is in SQLite:

  class normal pattern (base) : __tablename__ = '& lt; Tablename & gt; Id = column (integer, primary_key = true) field = column (string)  

for childA class you want to define a custom mapper that always includes The statement:

  metadata = metadata () parent_table = normal password .__ table__ child_table = table ('& lt; tablename'; metadata, column ('id', integer, Primary_key = true), column (child): with __table__ = childa id = column_property (parent_table.c.id, child_table.c.) - (originally) User_id) child_id = child_table.c.id  < / Pre> 

()


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -