During some set operations I encountered this error in Python:
TypeError: unhashable type: 'InstrumentedList'
What is an InstrumentedList
in Python? I only found a few references related to SQLAlchemy. Is this a SQLAlchemy implementation of lists or something?
By the way, it happens while doing:
set(self.some_list)
where
print type(self.some_list) # <type 'list'>
SQLAlchemy is a library that facilitates the communication between Python programs and databases. Most of the times, this library is used as an Object Relational Mapper (ORM) tool that translates Python classes to tables on relational databases and automatically converts function calls to SQL statements.
The sqlalchemy backref is one of the type keywords and it passed as the separate argument parameters which has to be used in the ORM mapping objects. It mainly includes the event listener on the configuration attributes with both directions of the user datas through explicitly handling the database relationships.
Yes, SQLAlchemy uses it to implement a list-like object which is aware of insertions and deletions of related objects to an object (via one-to-many and many-to-many relationships).
Yes it's part of SQLAlchemy API. Here is the class reference:
http://docs.sqlalchemy.org/en/latest/orm/collections.html#sqlalchemy.orm.collections.InstrumentedList
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With