I've problems to write a filter function:
user_q = meta.Session.query(model.BPUser)
user = user_q.filter(and_(model.BPUser.name=='%s' % username, \
model.BPUser.state.in_([0,1]))).first()
I've tried to load the in_ function by
>>> from sqlalchemy import in_
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name in_
>>> from sqlalchemy.sql import in_
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name in_
>>> from sqlalchemy.sql.expression import in_
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name in_
Any hints ?
vbr
Matt
in_ is a method on the column instance, there is no need to import it.
Wichert.
--
Wichert Akkerman <wic...@wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
> I've problems to write a filter function:
>
> user_q = meta.Session.query(model.BPUser)
> user = user_q.filter(and_(model.BPUser.name=='%s' % username, \
>
> model.BPUser.state.in_([0,1]))).first()
Additionally,there's no reason to do the string sub like that, this
should be fine:
user = user_q.filter(and_(model.BPUser.name==username, \
model.BPUser.state.in_([0,1]))).first()
Or if you have some condition where username might not be the right
type, str() it.
Cheers,
Ben