1

我有表名VenueSetting

id  prefix  type
------------------
1   456     1
2   8       2
3   4560    3

如何使用SqlAchemy ORM查询查询输入数字以匹配数据库中的前缀,反向版本like

像这样的查询

from_phone = '456789000'
session.query(VenueSetting).
         filter(from_phone.like(VenueSetting.prefix + '%')).
         first()

#expect result is record with id=1 in database
4

0 回答 0