当前位置: 代码迷 >> python >> 尝试安装postgis时遇到错误:“ postgis_lib_version”或附近的语法错误
  详细解决方案

尝试安装postgis时遇到错误:“ postgis_lib_version”或附近的语法错误

热度:25   发布时间:2023-07-16 09:37:40.0

我正在尝试安装postgis,并尝试将其与django集成。 我在这里关注教程。 它说以下

after connecting to db we need to add geo-extensions:

-- Enable PostGIS (includes raster)
CREATE EXTENSION postgis;
-- Enable Topology
CREATE EXTENSION postgis_topology;
-- fuzzy matching needed for Tiger
CREATE EXTENSION fuzzystrmatch;
-- Enable US Tiger Geocoder
CREATE EXTENSION postgis_tiger_geocoder;
check POSTGIS version:

postgis_lib_version();
as a tupple we add it to django settings:

POSTGIS_VERSION = (2, 1, 3)

这就是我所做的

mst=# \connect school
psql (10.5, server 10.4)
You are now connected to database "school" as user "mst".
school=# CREATE EXTENSION postgis;
CREATE EXTENSION
school=# CREATE EXTENSION postgis_topology;
CREATE EXTENSION
school=# CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION
school=# CREATE EXTENSION postgis_tiger_geocoder;
CREATE EXTENSION
school=# postgis_lib_version();
ERROR:  syntax error at or near "postgis_lib_version"
LINE 1: postgis_lib_version();

关于我为什么收到此错误的任何建议。 任何我可能会丢失或做错的事情?

调用函数时,应该在它之前有一个SELECT ,否则PostgreSQL不知道如何处理该函数。

SELECT postgis_lib_version();
  相关解决方案