i have a value that can be integer, float or string, and i create diferent columns:
#declarative
class MyClass(Base):
#id and other Columns
_value_str = Column(String(100))
_value_int = Column(Integer)
_value_float = Column(Float)
def __init__(self,...,value):
self._value_str = value if isinstance(value,(str,unicode)) else None
self._value_int = value if isinstance(value,int) else None
self._value_float = value if isinstance(value,float) else None
and i would like to do something like this:
>>> value = 'text'
>>> my_class = MyClass(value, ...)
>>> my_class.value
>>> 'text'
>>> session.add(my_class)
>>> session.commit()
#specialy this
>>> result = session.query(Myclass).filter(Myclass.value == 'text').one()
>>> print result.value
>>> 'text'
Maybe i have a design problem, i accept any good idea
I'm newbe in SQLAlchemy
Thanks