Perhaps I have been up too many hours, but my syntax foo is fizzling.
Given the following class, I want to compute the string length of
"position" instead of storing it as another attribute which can get out of
sync. eg.
class Position(Base):
__tablename__ = 'position'
id = Column(INTEGER, primary_key=True)
timestamp = Column(TIMESTAMP, nullable=False)
position = Column(TEXT, unique=True, nullable=False)
So to get all positions of string length 2, the following is not working:
from sqlalchemy.sql.expression import func
# ...
for position, in
session.query(Position.position).filter(func.length(Position.position == 2):
print(position)
Any insight offered would certainly be appreciated.
Thanks!
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/CAKeNXXtURxf-eXNaXn1woYE_q9i%3DggeopN%2B_%3D9hQb3FWfqqyLQ%40mail.gmail.com.