如何在中向postgresql数据库添加postgis扩展吉特拉比.ym

2024-05-23 22:53:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在gitlab-ci.yml文件中设置测试阶段,当配置postgis扩展到postgresql数据库时出错。在

{Django>我的数据库需要

我的最新版本gitlab-ci.yml

image: python:3.6

services:
  - postgres:9.6

variables:
  POSTGRES_DB: test_db
  POSTGRES_USER: test_user
  POSTGRES_PASSWORD: test_pass
  DATABASE_URL: "postgis://test_user:test_pass@postgres:5432/test_db"

stages:
  - test
  - build

test:
  stage: test
  script:
    - apt-get update -qy
    - apt-get -y install binutils libproj-dev gdal-bin postgis*
    - pip3 install pipenv
    - pipenv install --dev
    - export DATABASE_URL=$DATABASE_URL
    - pipenv run test

Gitlab管道错误响应:

^{pr2}$

Tags: installtestci数据库urldbymlpipenv
2条回答

尝试使用django documentation中的替代选项:

from django.contrib.postgres.operations import CreateExtension
from django.db import migrations

class Migration(migrations.Migration):

    operations = [
        CreateExtension('postgis'),
        ...
    ]

您可以使用已经具有postgis的服务并安装二进制文件,如下所示:

services:
  - mdillon/postgis:9.4

variables:
  POSTGRES_DB: "db_name"
  POSTGRES_USER: "db_user"
  POSTGRES_PASSWORD: "db_pwd"
  POSTGRES_HOST: "db"
  POSTGRES_PORT: "5432"
  DATABASE_URL: 
  "postgres://db_user:db_pwd@mdillon__postgis/db_name"

before_script:
  - apt-get update -qy
  - apt-get -y install binutils libproj-dev gdal-bin
  - python -V
  - pip3 install -r requirements.txt

参考文献: -https://www.hackzine.org/postgis-on-gitlab-ci.html

相关问题 更多 >