Sigma
Sigma

Reputation: 113

How to map more than one table to a class with SQLAlchemy

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).

Upvotes: 2

Views: 248

Answers (1)

Ben
Ben

Reputation: 11481

Have a look at this question: How to map one class against multiple tables with SQLAlchemy?

Upvotes: 1

Related Questions