0
在the SQLAlchemy Tutorial如何導入別名SQLAlchemy的功能
一個例子使用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'
>>>