I am trying to insert a record into a oracle db via sqlalchemy, here is my below model:
class Item(Base):
__tablename__ = 'items'
id = db.Column(db.Integer, db.Sequence('item_id_seq'), nullable=False, primary_key=True)
name = db.Column(db.String(128), nullable=True)
def __init__(self, name):
self.name = name
I have already created the table in the db by running the db migrate and upgrade. I am trying to insert a simple row in the db table as in :
test_obj = Item(name='item-1')
db.session.add(test_obj)
db.session.commit()
But the insert fails with the error TypeError: unhashable type: 'list'
But if I insert it along with the id (as below) and with the id initialized in the constructor, it inserts successfully.
test_obj = Item(id = 1, name='item-1')
db.session.add(test_obj)
db.session.commit()
class Item(Base):
...
def __init__(self, id, name):
self.id = id
self.name = name
Since I have set id with a sequence, it should auto increment and get inserted automatically, but this is not the case here, any help would be appreciated.