<s> """<STR_LIT>""" <EOL> from sqlalchemy import create_engine , MetaData , Table , Column , Integer , String <EOL> from sqlalchemy . orm import mapper , sessionmaker , polymorphic_union <EOL> metadata = MetaData ( ) <EOL> managers_table = Table ( '<STR_LIT>' , metadata , <EOL> Column ( '<STR_LIT>' , Integer , primary_key = True ) , <EOL> Column ( '<STR_LIT:name>' , String ( <NUM_LIT:50> ) ) , <EOL> Column ( '<STR_LIT>' , String ( <NUM_LIT> ) ) <EOL> ) <EOL> engineers_table = Table ( '<STR_LIT>' , metadata , <EOL> Column ( '<STR_LIT>' , Integer , primary_key = True ) , <EOL> Column ( '<STR_LIT:name>' , String ( <NUM_LIT:50> ) ) , <EOL> Column ( '<STR_LIT>' , String ( <NUM_LIT> ) ) <EOL> ) <EOL> engine = create_engine ( '<STR_LIT>' , echo = True ) <EOL> metadata . create_all ( engine ) <EOL> class Employee ( object ) : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __repr__ ( self ) : <EOL> return self . __class__ . __name__ + "<STR_LIT:U+0020>" + self . name <EOL> class Manager ( Employee ) : <EOL> def __init__ ( self , name , manager_data ) : <EOL> self . name = name <EOL> self . manager_data = manager_data <EOL> def __repr__ ( self ) : <EOL> return self . __class__ . __name__ + "<STR_LIT:U+0020>" + self . name + "<STR_LIT:U+0020>" + self . manager_data <EOL> class Engineer ( Employee ) : <EOL> def __init__ ( self , name , engineer_info ) : <EOL> self . name = name <EOL> self . engineer_info = engineer_info <EOL> def __repr__ ( self ) : <EOL> return self . __class__ . __name__ + "<STR_LIT:U+0020>" + self . name + "<STR_LIT:U+0020>" + self . engineer_info <EOL> pjoin = polymorphic_union ( { <EOL> '<STR_LIT>' : managers_table , <EOL> '<STR_LIT>' : engineers_table <EOL> } , '<STR_LIT:type>' , '<STR_LIT>' ) <EOL> employee_mapper = mapper ( Employee , pjoin , polymorphic_on = pjoin . c . type ) <EOL> manager_mapper = mapper ( Manager , managers_table , <EOL> inherits = employee_mapper , concrete = True , <EOL> polymorphic_identity = '<STR_LIT>' ) <EOL> engineer_mapper = mapper ( Engineer , engineers_table , <EOL> inherits = employee_mapper , concrete = True , <EOL> polymorphic_identity = '<STR_LIT>' ) <EOL> session = sessionmaker ( engine ) ( ) <EOL> m1 = Manager ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> e1 = Engineer ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> e2 = Engineer ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> session . add ( m1 ) <EOL> session . add ( e1 ) <EOL> session . add ( e2 ) <EOL> session . commit ( ) <EOL> print ( session . query ( Employee ) . all ( ) ) </s>
