Not Available
Not Available

Reputation: 3355

SQLAlchemy mapped_collection on table itself?

I was wondering if it was possible to somehow fetch the objects from a table and get them returned indexed by an arbitrary value, similar to mapped_collection.

I realize that this is easy to work around (And that I am already doing). But I was just wondering if this was possible.

Upvotes: 0

Views: 79

Answers (1)

zzzeek
zzzeek

Reputation: 75137

what's wrong with :

my_mapping = dict(Session.query(MyClass.somekey, MyClass))

?

I do that all the time to make a quick cache of something.

Upvotes: 1

Related Questions