我正在使用运行flask应用程序的docker-compose容器。在该容器中,将启动具有Postgis扩展名的Postgres容器(mdillon/postgis图像)。一切运行正常,但单个Postgis扩展名(地理)无法正常工作,我无法解释。
我的docker-compose.yml:
version: '3.7'
services:
flask:
build: .
entrypoint:
- flask
- run
- --host=0.0.0.0
environment:
FLASK_DEBUG: 1
FLASK_APP: app.py
ports:
- '5000:5000'
volumes:
- './app:/app'
networks:
- db_net
db:
image: mdillon/postgis
networks:
- db_net
networks:
db_net:
运行sudo docker-compose up --build
后,它将创建两个容器:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1836d3d15765 img_flask "flask run --host=0.…" 9 minutes ago Up 9 minutes 80/tcp, 443/tcp, 0.0.0.0:5000->5000/tcp img_flask_1
b25752af45ad mdillon/postgis "docker-entrypoint.s…" 13 minutes ago Up 13 minutes 5432/tcp img_db_1
打开flask应用程序或数据库日志时,它声明以下内容:
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedObject) type "geography" does not exist
LINE 7: geom geography(POINT,4326)
检查postgis正确,并且在数据库中重新安装它不能解决问题。软件包如下:
List of installed extensions
Name | Version | Schema | Description
------------------------+---------+------------+---------------------------------------------------------------------
fuzzystrmatch | 1.1 | public | determine similarities and distance between strings
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
postgis | 2.5.0 | public | PostGIS geometry, geography, and raster spatial types and functions
postgis_tiger_geocoder | 2.5.0 | tiger | PostGIS tiger geocoder and reverse geocoder
postgis_topology | 2.5.0 | topology | PostGIS topology spatial types and functions
(5 rows)
总而言之,我的容器可以正常工作,并且Postgis安装得很好。但是当查询请求地理功能时会出现问题。是否有人可以提供有关如何解决此问题的建议?谢谢!
答案 0 :(得分:0)
已修复,偶然在其他数据库中工作。 @杰里米,谢谢!