0

我创建了以下 SQL 查询来查找一英里内的所有用户,它似乎工作正常:

SELECT * FROM user 
WHERE ST_DWithin(
    user.location, 
    ST_MakePoint(-2.242631, 53.480759)::geography, 1609) 
);

但是我想将其转换为烧瓶/sqlalchemy/geoalchemy 查询?

4

1 回答 1

0

尝试这样的事情:

DISTANCE = 100 #100 meters
db.session.query(User).filter(func.ST_DWithin(User.location, cast(funct.ST_SetSRID(func.ST_MakePoint(-2.242631, 53.480759), 1609), Geography), DISTANCE)).all()
于 2019-02-12T03:52:22.120 回答