Hi
Brand new to SA. The database I'm using uses a string field to represent
boolean values, using T or F.
I want to use the SA boolean type but can't figure out how to get it to let
me.
Here is what I'm doing so far:
class RequisitionPeriod(Base):
__tablename__ = 'requisition_period'
id = Column(BigInteger, primary_key=True)
week_ends = Column(Date)
order_cutoff = Column(Date)
current = Column(String(1), default='F')
@property
def current(self):
return True if self.current_ == 'T' else False
@current.setter
def current(self, current):
if isinstance(current, bool):
self.current_ = 'T' if current else 'F'
def __repr__(self):
return '%s' % self.week_ends
But, this doesn't allow me to query easily off the 'current' column.
Any advice for a newb?
I've tried both...
rp = session.query(RequisitionPeriod).filter_by(current='T').one()
rp = session.query(RequisitionPeriod).filter_by(current=True).one()
Both return
Traceback (most recent call last):
File "/home/jim/dev/qlf/qlf/model.py", line 633, in <module>
rp = session.query(RequisitionPeriod).filter_by(current='T').one()
File
"/home/jim/.local/lib/python2.7/site-packages/sqlalchemy/orm/query.py",
line 2960, in one
raise orm_exc.NoResultFound("No row was found for one()")
sqlalchemy.orm.exc.NoResultFound: No row was found for one()
The data should be returning 1 row.
Any help would be greatly appreciated.
-Jim
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.