tags:

views:

28

answers:

2

I'm new to sqlalchemy and am trying to map several tables to a class.

The tables are constructed like so:

Types
  -typeID
  -typeName
  -groupID
  ...

TypeAttributes
  -typeID
  -attributeID
  -attributeValueInt
  -attributeValueFloat

The idea is to have sqlalchemy map a from TypeAttributes to normal class attributes. As added complexity attributeValueInt and attributeValueFloat are exclusive. By which I mean each attributeID will have either an int or a float assossiated and the other will be null.

Any ideas how this could be done? or advice on a better way to do it (I have no control over the Database itself).

A: 

Thanks Ben.

That got me pointed in the right direction. To supplement the example I had to use a composite column mapped to a class with a method that checked which attributeValue was the relevant one.

Sigma