Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
191 views
in Technique[技术] by (71.8m points)

python - SQL Alchemy - How to use built-in function in PostgreSQL database?

I want put this query into code:

select * from st_geomfromtext('POINT(106.69588536141288 10.782847409207672)')

Here is what I did in code:

class st_geomfromtext(GenericFunction):
    name = 'st_geomfromtext'

query = Session.query(func.st_geomfromtext('POINT(106.69588536141288 10.782847409207672)')).all()

Here is what I receive:

LINE 1: SELECT st_geomfromtext('POINT(106.69588536141288 10.78284740...
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Are you able to validate your query directly against PostgreSQL?

Function may actually not be there. st_geomfromtext is part of PostGIS, depending on the PostgreSQL version, you may need to install / enable it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...