Python + SqlAlchemy 'init' with single table inheritance -


got problems sqlalchemy thing.

i've defined database, relevant parts per below...

class person(base):     __tablename__ = 'person'     #     id = column(integer, primary_key=true)     person_type = column(string(32), nullable=false)     name = column(string(50))     address = column(string(120))     phonenum = column(string(20))     __mapper_args__ = {'polymorphic_on':person_type}  #  class student(person):     __mapper_args__ = {'polymorphic_identity': 'student'}     dob = column(date) 

i've other subclasses of 'person' too. i'm having problems way 'init' should look. last attempt was..

for 'person'..

def __init__(self, a_name, a_address, a_phonenum, a_person_type = none):     self.name = a_name     self.address = a_address     self.phonenum = a_phonenum 

and 'student'..

def __init__ (self, a_name, a_address,a_phonenum, a_dob=none, a_stud_caregiver_id=none, a_person_type = 'student'):     self.name = a_name     self.address = a_address     self.phonenum = a_phonenum     self.dob = a_dob     self.stud_caregiver_id = a_stud_caregiver_id     self.person_type = a_person_type 
  • but though creates database ok, when come 'init' students, i'm getting messages along lines of...

sqlalchemy.exc.invalidrequesterror: 1 or more mappers failed initialize - can't proceed initialization of other mappers. original exception was: class object expected, got 'table('person', metadata(bind=none)....

i've tried with/without person_type parameter .. really, i'm shooting in dark.

i've done dumb, what? thanks!


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -