例では次を使用しますaliased
。
>>> from sqlalchemy import func
>>> ua = aliased(User)
>>> q = q.from_self(User.id, User.name, ua.name).\
... filter(User.name < ua.name).\
... filter(func.length(ua.name) != func.length(User.name))
しかし、0.6.1 では動作しません:
>>> from sqlalchemy import func
>>> ua = aliased(User)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
ua = aliased(User)
NameError: name 'aliased' is not defined
>>> ua = aliased(User)
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
ua = aliased(User)
NameError: name 'aliased' is not defined
>>> ua = sqlalchemy.aliased(User)
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
ua = sqlalchemy.aliased(User)
NameError: name 'sqlalchemy' is not defined
>>> import sqlalchemy
>>> ua = sqlalchemy.aliased(User)
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
ua = sqlalchemy.aliased(User)
AttributeError: 'module' object has no attribute 'aliased'
>>>