python - TypeError: __init__() got an unexpected keyword argument error -
i have 6 tables in sqlite database , i'm trying add new row in 1 of tables using sqlalchemy. here tables:
class dsource(base): __tablename__ = 'dsource' source_id = column(integer, primary_key=true) subjects= relationship("subject") class subject(base): __tablename__ = 'subject' subject_id = column(integer, primary_key=true) source_id=column(integer, foreignkey("dsource.source_id"),nullable=false) sequences= relationship("sequence") class sequence(base): __tablename__ = 'sequence' sequence_id = column(integer, primary_key=true) subject_id=column(integer, foreignkey("subject.subject_id"),nullable=false)
here code i'm using add new sequence table:
engine = create_engine('sqlite:////desktop/emotion_data/test.db',echo=true) session = sessionmaker(bind=engine) session = session() new_sequence=sequence(sequence_id=0,subject_id=1) session.add(new_sequence) session.commit()
but i'm getting error:
typeerror: __init__() got unexpected keyword argument 'subject_id'
i have no idea mean, have imported "subject" instance "subject_id=0" table, subject_id=0 in database.
can please me?
your code looks fine, if exception raises when split source different files. there must name conflict, sequence
class may not expected, can check prepending lines before init process.
print sequence.__module__ print type(sequence)
Comments
Post a Comment